python 开发之selenium

发布时间:2020-08-05 18:58:48 作者:weady
来源:网络 阅读:344

使用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

推荐阅读:
  1. Python动态网页爬虫技术
  2. Python学习路线:成为Python工程师有多难?

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python 爬虫 sel

上一篇:华为单臂路由——实战

下一篇:关于flex使用指南

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》