代码拉取完成,页面将自动刷新
同步操作将从 wangqiyuan/traderStock-gui 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- 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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。