爬取动态的网页。
来源:互联网 发布:中昌数据什么时候开盘 编辑:程序博客网 时间:2024/05/18 00:58
#coding=utf-8#import webdriver from selenium#要安装 pip install seleniumimport re#yum install nodejs --> npm install -g cnpm --registry=https://registry.npm.taobao.org#npm install phantomjs-prebuilt@2.1.14 --ignore-scripts -> pip install phantomjsfrom selenium import webdriver# load PhantomJS drivercur_url="http://bj.news.163.com/"#在ubuntu 下 which phantomjsdriver = webdriver.PhantomJS('/usr/bin/phantomjs')# set window size, better to fit the whole page in order to# avoid dynamically loading datadriver.set_window_size(1280, 2400) # optional# data page contentdriver.get(cur_url)# use page_source to get html contentcontent = driver.page_sourceprint content# driver.find_element_by_class_name()# data_time=re.findall('http:\/\/(.+\.){1,}163.com\/\d{2}\/\d{4}\/\d{2}\/.+\.html',content)# print data_timefrom bs4 import BeautifulSoupsoup = BeautifulSoup(content, 'lxml')urls=[]news_content=[]for link in soup.select('div.na_detail > div.news_title > h3 > a'): urls.append(link.get('href')) news_content.append(link.text)print urlsfor i in news_content: print iprint len(news_content)print len(news_content)
阅读全文
0 0
- 爬取动态的网页。
- C#爬取动态网页
- 爬取网页动态数据
- 爬取网页动态内容
- 定向爬虫:动态加载网页的爬取
- 基于Python3的phantomJs+Selenium动态网页爬取技术
- 爬虫实战2—动态网页的爬取
- python爬取百度搜索动态网页
- selenium+ phantomjs实现动态网页爬取
- selenium+ Phantomjs爬取动态网页
- python爬取静态和动态网页
- Scrapy+phantomjs爬取动态网页数据
- python + Scrapy 爬取动态网页
- 用scrapy爬取网页时网页JS动态生成的问题解决办法
- 爬取数据遇到的问题--动态显示,网页中没有所要的数据
- 使用selenium的webdriver动态爬取网页时遇到的问题
- htmlunit爬取javascript、Ajax 动态生成的网页;jsoup解析XML文档
- 利用htmlunit和jsoup来实现爬取js的动态网页
- EasyTalk 项目介绍
- Diplomas and Certificates (Codeforces
- SVM+HOG对图像进行多分类(OpenCV实现)
- MapReduce练习:DataJoin联结练习
- [iOS [转] CAEmitterLayers属性解释] 鱼缸气泡效果(非完美)
- 爬取动态的网页。
- 一次完整的HTTP请求过程
- 教你如何迅速秒杀掉:99%的海量数据处理面试题
- 为什么选择Nginx
- iOS 长按复制文本
- Object类与reflect包
- Tensorflow入门解读
- (function($) {…})(jQuery);
- mysql5.7.17安装配置图文教程