码迷,mamicode.com
首页 > 编程语言 > 详细

python 开发之selenium

时间:2018-10-22 20:30:34      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:信息   tor   import   爬虫   分析   name   加载   directory   获取   

使用selenium和PhantomJS来模拟浏览器点击下一页,获取页面数据进行抓取分析
用python写爬虫的时候,主要用的是selenium的Webdriver来获取页面数据
使用webdriver需要安装对应浏览器的driver,并加入到环境变量中
from selenium import webdriver
driver = webdriver.PhantomJS() 使用PhantomJS浏览器创建浏览器对象
driver.get("https://www.douyu.com/directory/all") 使用get方法加载页面
driver.find_element_by_class_name("shark-pager-next").click() class="shark-pager-next"是下一页按钮,click() 是模拟点击
利用BeatuifulSoup 对页面信息进行提取
模拟点击时需要安装 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip

python 开发之selenium

标签:信息   tor   import   爬虫   分析   name   加载   directory   获取   

原文地址:http://blog.51cto.com/weadyweady/2307341

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!