首页 > 编程语言 > 详细

python 爬虫

时间:2017-01-01 07:39:15      阅读:228      评论:0      收藏:0      [点我收藏+]

网页访问常用到库:

requests(网页请求)

BeautifulSoup(从网页抓取数据)

selenium(模拟浏览器行为)

PhantomJS(虚拟浏览器)

import requests
from bs4 import BeautifulSoup
from selenium import webdriver

res = requests.get(url)
res.encoding = utf-8
soup = BeautifulSoup(res.text, html.parser)

 

import requests
from bs4 import BeautifulSoup
from selenium import webdriver

res = requests.get(url)
res.encoding = ‘utf-8‘
soup = BeautifulSoup(res.text, ‘html.parser‘)

定时爬取数据:

import time

time.sleep(10)

断线重连解决方法:

引入新函数reloading()

def reloading()
  try:

  except:
    reloading()

  

python 爬虫

原文:http://www.cnblogs.com/xingchendahai/p/6240599.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!