Selenium 获取动态js的网页
Selenium基于webkit实现爬虫功能
http://www.cnblogs.com/luxiaojun/p/6144748.html
https://www.cnblogs.com/chenqingyang/p/3772673.html
现在headless chrome替代 PhantomJS
https://zhuanlan.zhihu.com/p/27100187
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
import io dcap = dict(DesiredCapabilities.PHANTOMJS) #设置userAgent
dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0 ") obj = webdriver.PhantomJS(executable_path='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts\phantomjs.exe',desired_capabilities=dcap) #加载网址
obj.get('http://chart.icaile.com/sd11x5.php')#打开网址 #time.sleep(10)
pageSource = obj.page_source
print(pageSource) obj.quit()
获取的网页内容后,可以使用beautifulsoup来分析
https://cuiqingcai.com/1319.html
直接获取表格的文本
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
import io dcap = dict(DesiredCapabilities.PHANTOMJS) #设置userAgent
#dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0 ") obj = webdriver.PhantomJS(executable_path='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts\phantomjs.exe',desired_capabilities=dcap) #加载网址
obj.get('http://chart.icaile.com/sd11x5.php')#打开网址 text = obj.find_element_by_id("fixedtable").text print(text) obj.quit()
import time
import io
import re
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities dcap = dict(DesiredCapabilities.PHANTOMJS) #设置userAgent
dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0 ") obj = webdriver.PhantomJS(executable_path='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts\phantomjs.exe',desired_capabilities=dcap) #加载网址
obj.get('http://chart.icaile.com/sd11x5.php')#打开网址 text = obj.find_element_by_id("fixedtable").text
#time.sleep(10)
#pageSource = obj.page_source
#print(pageSource) #print(text) page = obj.page_source url_context = re.findall('href=\"(.*?)\"',page,re.S)
url_list = []
for url in url_context:
if 'http'in url:
print(url) obj.quit()
Selenium 获取动态js的网页的更多相关文章
- Selenium获取动态图片验证码
Selenium获取动态图片验证码 关于图片验证码的文章,我想大家都有一定的了解了. 在我们做UI自动化的时候,经常会遇到图片验证码的问题. 当开发不给咱们提供万能验证码,或者测试第三方网站比如知乎的 ...
- Python网络爬虫笔记(四):使用selenium获取动态加载的内容
(一) 说明 上一篇只能下载一页的数据,第2.3.4....100页的数据没法获取,在上一篇的基础上修改了下,使用selenium去获取所有页的href属性值. 使用selenium去模拟浏览器有点 ...
- 在python使用selenium获取动态网页信息并用BeautifulSoup进行解析--动态网页爬虫
爬虫抓取数据时有些数据是动态数据,例如是用js动态加载的,使用普通的urllib2 抓取数据是找不到相关数据的,这是爬虫初学者在使用的过程中,最容易发生的情况,明明在浏览器里有相应的信息,但是在pyt ...
- selenium获取动态网页信息(某东)-具体配置信息
需要安装的包: selenium 关于软件的驱动:selenium之 驱动环境配置chrome.firefox.IE 1 # encoding:utf-8 2 # Author:"richi ...
- 【Todo】phantomjs获取动态网页
上面一篇文章,使用了cheerio, http, request等库,来抓取了Lofter上面的美女图片. 但是很多网页是动态渲染的.据了解,Phantom.js 可以获取动态渲染的网页 http:/ ...
- Python3.x:Selenium+PhantomJS爬取带Ajax、Js的网页
Python3.x:Selenium+PhantomJS爬取带Ajax.Js的网页 前言 现在很多网站的都大量使用JavaScript,或者使用了Ajax技术.这样在网页加载完成后,url虽然不改变但 ...
- [Python爬虫] Selenium+Phantomjs动态获取CSDN下载资源信息和评论
前面几篇文章介绍了Selenium.PhantomJS的基础知识及安装过程,这篇文章是一篇应用.通过Selenium调用Phantomjs获取CSDN下载资源的信息,最重要的是动态获取资源的评论,它是 ...
- JS获取屏幕,浏览器窗口大小,网页高度宽度(实现代码)_javascript技巧_
JS获取屏幕,浏览器窗口大小,网页高度宽度(实现代码)_javascript技巧_--HTML5中文学习网 http://www.html5cn.com.cn/shili/javascripts/79 ...
- [Python爬虫] 之一 : Selenium+Phantomjs动态获取网站数据信息
本人刚才开始学习爬虫,从网上查询资料,写了一个利用Selenium+Phantomjs动态获取网站数据信息的例子,当然首先要安装Selenium+Phantomjs,具体的看 http://www.c ...
随机推荐
- [TypeScript] Catch unsafe use of "this" in TypeScript functions
this is probably the most tricky thing to use in JavaScript and therefore TypeScript. Fortunately th ...
- MySQL经常使用的面试题
1.怎样登陆mysql数据库 MySQL -u username -p 2.怎样开启/关闭mysql服务 service mysql start/stop 3.查看mysql的状态 service m ...
- [转至云风的博客]谈谈陌陌争霸在数据库方面踩过的坑( Redis 篇)
« 谈谈陌陌争霸在数据库方面踩过的坑(芒果篇) | 返回首页 | linode 广告时间 » 谈谈陌陌争霸在数据库方面踩过的坑( Redis 篇) 注:陌陌争霸的数据库部分我没有参与具体设计,只是参与 ...
- ITFriend创业败局(一):选择创业方向和寻找合伙人,创业失败的2个关键点
这次创业惨淡收场,最主要的原因是没有选择一个合适的创业方向,没有找到合适的创业合伙人. 首先要说到创业方向,因为不同的创业方向需要组建不同的创业团队.我个人比较偏好,软件.网络.互联网等有一 ...
- 简洁常用权限系统的设计与实现(四):不维护level,用递归方式构造树
第三篇中,我们通过维护节点的深度level,通过迭代所有的节点,只需要一次,就构造了树. 本篇,换一种方式. 好处是:不维护节点的深度level,增加和修改节点时,也不用维护.递归实现,代码比较清晰 ...
- Google Android Studio Kotlin
Google Android Studio Kotlin 开发环境配置 Google 近日开发者大会宣布Kotlin成为Android开发的第一级语言,即Android官方开发语言,可见Google对 ...
- Spring中WebApplicationInitializer的理解
现在JavaConfig配置方式在逐步取代xml配置方式.而WebApplicationInitializer可以看做是Web.xml的替代,它是一个接口.通过实现WebApplicationInit ...
- 【16.23%】【codeforces 586C】Gennady the Dentist
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Hexo里如何添加广告
前期先用Hexo做个人网站,模板可以用https://github.com/828768/maupassant-hexo,关于如何加入广告,可以看一下https://sobaigu.com/hexo- ...
- Ubuntu 16.04安装MinGW32(在/etc/apt/sources.list里添加源)
Ubuntu 16.04下直接使用命令安装MinGW32: sudo apt-get install mingw32 但是,会报错: Unable to locate package mingw3 ...