维普 _自动导出xml
来源:互联网 发布:八爪鱼客户端软件 编辑:程序博客网 时间:2024/05/22 06:39
#!/usr/bin/python#encoding=utf-8__author__ = 'Administrator'from bs4 import BeautifulSoupimport seleniumimport sysimport urllibimport requestsimport timeimport reif __name__ == "__main__": import os from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'} chromedriver = "/home/henson/Documents/pycharm/webdriver/chromedriver" chromeOptions = webdriver.ChromeOptions() prefs = {"download.default_directory": "/home/henson/Downloads/vp/recover"} #下载路径 chromeOptions.add_experimental_option("prefs", prefs) os.environ["webdriver.chrome.driver"] = chromedriver driver = webdriver.Chrome(chromedriver,chrome_options=chromeOptions) driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") #下载链接可改page+size driver.get('http://qikan.cqvip.com/zk/search.aspx?from=zk_search&key=U%3D%E7%94%9F%E6%80%81%E6%B2%BB%E7%90%86%E4%B8%8E%E6%81%A2%E5%A4%8D&size=50&page=1#search-result-list') currentURL=driver.current_url time.sleep(2) k=1 for j in range(3, 300): #下载选页 driver.find_element_by_xpath('//*[@id="searchop"]/div[1]/a[1]').click() #全选 driver.find_element_by_xpath('//*[@id="searchop"]/div[1]/a[3]').click() #导出 now_handle = driver.current_window_handle # 获取当前窗口句柄 all_handles = driver.window_handles # 获取所有窗口句柄 time.sleep(2) for handle in all_handles: if (handle != now_handle): driver.switch_to_window(handle) #print("new web" + driver.current_url) driver.find_element_by_xpath('//*[@id="showinfobtn3"]').click() #XML driver.find_element_by_xpath('//*[@id="exportbtn"]').click() #开始导出 driver.close() print(now_handle) # 输出主窗口句柄 driver.switch_to_window(now_handle) # 返回主窗口 driver.find_element_by_xpath('//*[@id="searchop"]/div[1]/a[2]').click() #清除 driver.find_element_by_xpath( '//*[@id="body"]/div/div[3]/div[6]/div[2]/span[2]/a[2]').click() #下一页 time.sleep(2) currentURL = driver.current_url
用来获取跳转的当前窗口
now_handle = driver.current_window_handle # 获取当前窗口句柄
all_handles = driver.window_handles # 获取所有窗口句柄
设置timeout配合until来确定是否加载完成
阅读全文
0 0
- 维普 _自动导出xml
- 导出数据到xml(自动下载)
- 使用XML方式导出Excel(自动分页)
- XML 导出
- 导出XML
- (笔记)Spring实战_最小化Spring XML配置(1)_自动装配Bean属性
- 工作_导出总结
- java_excel_导入_导出
- sql导出文件,导出xml
- ORACLE自动导出备份
- apex 自动导出application
- 导出数据库_表结构_数据
- xml模板导出Excel
- 数据库导出xml文件
- ruby 导出xml
- Oracle 导出导入XML
- DataGridView导出excel/xml
- 导出XML数据
- 利用Theme自定义Activity间的切换动画
- 2017.8.5暑假集训第六天
- [Spring Boot] 1. Spring Boot启动过程源码分析
- 随机快速排序的代码实现
- C++中变量的存储类别和属性
- 维普 _自动导出xml
- Hihicoder 题目1 : Trie树 经典字典树
- POJ 1703 Find them, Catch them(并查集高级应用)
- android WebView 长按自由复制文字,进入文字选择模式
- Android 面试精华题目总结
- bzoj1911 [Apio2010]特别行动队(斜率优化)
- 软件概要设计做什么,怎么做
- Python正则表达式基础
- 开发JDBCutil工具类