python selenium 获取动态网页数据
来源:互联网 发布:在线监测数据造假 编辑:程序博客网 时间:2024/05/09 10:41
# -*- coding:utf-8 -*-import requestsfrom bs4 import BeautifulSoupfrom selenium import webdriverimport timeimport jsonimport sysreload(sys)sys.setdefaultencoding("utf-8")curpath=sys.path[0]print curpathdef getData(url): driver=webdriver.Chrome() driver.set_page_load_timeout(40) time.sleep(3) html=driver.get(url[0]) for page in range(1): html=driver.page_source soup=BeautifulSoup(html,'lxml') table=soup.find('div',class_="unit_loan_prj_detail") name=[] for th in table.find_all('span',class_="prolist_info_title"): name.append(th.get_text()) i=0 for tr in table.find_all('span',class_="prolist_info_detail"): dic={} value=tr.get_text() if value is not None: dic[name[i]]=value else: for td in tr.find_all('span'): dic[name[i]]=td.get_text() i+=1 jsonDump(dic,url[1])def jsonDump(_json,name): with open(curpath+'/'+name+'.json','a')as outfile: json.dump(_json,outfile,ensure_ascii=False) with open(curpath+'/'+name+'.json','a')as outfile: outfile.write(',\n')if __name__=='__main__': url=['http://www.powerec.net/gdwz-web/html/xjxx/inquiry_detail.html?inq_h_id=ZGFmNTM2ZjctOWFlYi00ZDEyLWEyZjItNDFjNjAxYmY4MTZj','test'] getData(url)
阅读全文
0 0
- python selenium 获取动态网页数据
- python+selenium+PhantomJS抓取ajax动态网页数据
- python下利用Selenium获取动态页面数据
- selenium + python 获取table数据
- python获取完整网页内容(即包括js动态加载的):selenium+phantomjs
- Python抓取网页动态数据——selenium webdriver的使用
- Python网页测试库selenium,动态网页抓取
- selenium自动化测试工具开发python爬虫-动态加载页面数据获取
- 动态网页解析 Selenium
- 动态网页解析 Selenium
- selenium抓取动态网页
- 用Python获取网页数据
- 用python+selenium+firefox爬取动态网页
- Python使用Selenium和PhantomJS解析动态JS的网页
- Python使用Selenium和PhantomJS解析动态JS的网页
- 为采集动态网页安装和测试Python Selenium库
- 使用Python+selenium+BeautifulSoup抓取动态网页的关键信息
- python+selenium+PhantomJS爬取网页动态加载内容
- 用户名+is not in the sudoers file. This incident will be reported.
- class_create
- VS调试-附加到进程
- Codeforces327C Magic Five[组合数学]
- 自己动手实现集合框架类(四)之LinkedHashMap
- python selenium 获取动态网页数据
- shell进度条
- 小仙女-Jquery基础
- C++开源代码项目汇总 (转)
- 【Oracle学习笔记】单行函数
- Linux 权限管理命令(上)
- struts2+hibernate+spring整合过程中遇到的问题
- Java关于new的问题
- Spring获取properties的值[L]