python开发之硒

使用硒和PhantomJS来模拟浏览器点击下一页,获取页面数据进行抓取分析
用python写爬虫的时候,主要用的是硒的Webdriver来获取页面数据
使用Webdriver需要安装对应浏览器的驱动程序,并加入到环境变量中从硒进口Webdriver

司机=webdriver.PhantomJS()使用PhantomJS浏览器创建浏览器对象
driver.get (“https://www.douyu.com/directory/all")使用得到方法加载页面
driver.find_element_by_class_name (“shark-pager-next") .click()类=皊hark-pager-next"是下一页按钮,单击()是模拟点击
利用BeatuifulSoup对页面信息进行提取
模拟点击时需要安装https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip

python开发之硒