2 Star 0 Fork 16

wangqiyuan/traderStock-gui

forked from macroan/traderStock-gui 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
autodownload.py 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
macroan 提交于 2018-02-06 15:12 . no commit message
# -*- coding: utf8 -*-
import urllib2
import urllib
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.chrome.options import Options
def test_page():
url = 'http://blog.sina.com.cn/u/5230963627'
chrome_options = Options()
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=chrome_options)
#driver = webdriver.Chrome()
driver.get(url)
targeturl = driver.find_element_by_link_text("掌合久主力资金量化数据每日盘后更新20180201").get_attribute("href")
driver.get(targeturl)
driver.refresh()
print(driver.current_url) # 当前页面url
#print(driver.page_source) # 当前页面url
#test_page()
def test_ckick():
url = 'https://pan.baidu.com/s/1d065PG'
chrome_options = Options()
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=chrome_options)
#driver = webdriver.Chrome()
driver.get(url)
elem = driver.find_element_by_id('ali93J1')
elem.send_keys('aijp')
#elem.send_keys(Keys.ENTER) #点击键盘上的Enter按钮
#driver.find_element_by_id("epcnAZEL").click()
#driver.find_element_by_id("epcnAZEL").send_keys(Keys.ENTER)
#driver.find_element_by_xpath(".//*[@id='epcnAZEL']/a").click()
#driver.find_element_by_xpath(".//*[@id='epcnAZEL']/a").send_keys(Keys.ENTER)
js = "var q=document.getElementById('epcnAZEL').children[0].click()"
driver.execute_script(js)
driver.refresh()
print(driver.title) # 页面标题
print(driver.current_url) # 当前页面url
print(driver.page_source) # 页面源码
#test_ckick()
def click_download():
chrome_options = Options()
chrome_options.add_argument('--headless')
prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': 'D:\\dzh365\\USERDATA'}
chrome_options.add_experimental_option('prefs', prefs)
url = 'https://pan.baidu.com/s/1d065PG'
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(url)
elem = driver.find_element_by_id('ali93J1')
elem.send_keys('aijp')
js = "var q=document.getElementById('epcnAZEL').children[0].click()"
driver.execute_script(js)
driver.refresh()
time.sleep(8)
driver.find_element_by_xpath('//*[@id="layoutMain"]/div[1]/div[1]/div/div[2]/div/div/div[2]/a[2]').click()
print(driver.title) # 页面标题
#print(driver.current_url) # 当前页面url
#print(driver.page_source) # 页面源码
time.sleep(600)
click_download()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wangqiyuan2/traderStock-gui.git
git@gitee.com:wangqiyuan2/traderStock-gui.git
wangqiyuan2
traderStock-gui
traderStock-gui
master

搜索帮助