美文网首页
(一)爬虫综览

(一)爬虫综览

作者: 交易狗二哈 | 来源:发表于2017-03-24 20:41 被阅读69次

一、网络数据采集

涉及内容:
数据库、网络服务器、HTTP协议、HTML语言、网络安全、图像处理、数据科学等内容。

二、开发环境

  • Python版本:Python3.5
  • 操作系统 : Win10
  • IDE : 系统IDLE 、Pycharm

三、相关库

  • urllib
  • requests
  • selenium
  • re
  • BeautifulSoup
  • selenium
  • threading 、 muitiprocess
  • mysql.connector
  • xlsxwriter
  • scrapy

四、步骤工具

(一) 获取网页,请求数据

  • urllib
  • requests
  • selenium
1、
from urllib.request import urlopen
html = urlopen(url)
# html.read()    为未处理的二进制网页源代码
soup = BeautifulSoup(html.read(), 'lxml') #网页源代码
#加不加 .read 好像没差
2、
import requests
html = requests.get(url, headers=headers)
# html.text  为未处理的网页源代码
soup = BeautifulSoup(html.text, 'lxml')       
# 得加 .text
3、
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get(url)
driver.page_source #为未处理的网页源代码

(二) 提取内容

  • re
  • BeautifulSoup
  • selenium
1、

re 匹配

2、

BeautifulSoup
find、 find_all、 select
网页标签,selector

3、

find_elements...
网页标签,selector,xpath

(三) 下载内容

  • open...write
  • urllretrieve
  • requests
下载图片等文件
1、
from urllib.request import urlretrieve
urlretrieve(url, filename=None, reporthook=None, data=None)
2、
html = urlopen(imageUrl)
data = html.read()
f= open(fileName,'wb')
f.write(data)
f.close()
3、
import requests
picture = requests.get(url, headers=headers)
        if picture.status_code == 200: 
        open(path, 'wb').write(picture.content)

(四) 储存

  • csv
  • xlsxwriter
  • mysql.connector
  • pymongdb

(五) 模拟浏览器

selenium
splinter

(六) 中级爬虫框架

  • scrapy

相关文章

  • (一)爬虫综览

    一、网络数据采集 涉及内容:数据库、网络服务器、HTTP协议、HTML语言、网络安全、图像处理、数据科学等内容。 ...

  • Json-数据交换语言

    综览 产生时间:1999年 发展过程 JSON格式是1999年《JavaScript Programming La...

  • SHA家族-安全散列算法

    综览 安全散列算法secure hash algorithm ,是一个密码散列函数家族 是fips认证的五种安全散...

  • 100%新能源供电的电网可以实现吗?

    今年6月份《IEEE综览(IEEE Spectrum)》网站刊发了一篇长篇报道,详细记录了活力新能源公司(Vibr...

  • 爬虫入门基础

    Day01 一、爬虫介绍 什么是爬虫 Python爬虫的优势 Python爬虫需要掌握什么 爬虫与反爬虫与反反爬虫...

  • 01-认识爬虫

    一、爬虫介绍 什么是爬虫 Python爬虫的优势 Python爬虫需要掌握什么 爬虫与反爬虫与反反爬虫三角之争 网...

  • 11.20-11.26

    本周目标 爬虫 爬虫 爬虫 爬虫

  • Python代理IP爬虫的简单使用

    前言 Python爬虫要经历爬虫、爬虫被限制、爬虫反限制的过程。当然后续还要网页爬虫限制优化,爬虫再反限制的一系列...

  • 讲章|雅各生平之雅各的出生

    雅各的一生综览: 出生在庇耳拉海莱(25:11,25-26)在此地两次欺负他哥哥(27:)在伯特利遇见神(28:)...

  • 约翰福音概论

    第一课 约翰福音概论 教导重点:使用提纲和20:30-31的目的声明对全书给予介绍和综览。 教导方式: 1、用大纲...

网友评论

      本文标题:(一)爬虫综览

      本文链接:https://www.haomeiwen.com/subject/lkafottx.html