0
我無法點擊天的按鈕。如何使用Selenium從頁面中刪除所有數據?
from selenium import webdriver
browser = webdriver.Chrome()
url = "http://rate.am/en/armenian-dram-exchange-rates/banks/non-cash"
browser.get(url)
from selenium import *
import time
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from time import*
進口我曾嘗試編寫代碼,這將轉到頁所有必要的工具後,單擊歷史數據和按日期去,但我有問題,點擊天按鈕
browser = webdriver.Chrome()
url = "http://rate.am/en/armenian-dram-exchange-rates/banks/non-cash"
browser.get(url)
all_data=browser.find_element_by_xpath('//*[@id="aspnetForm"]/div[3]/div[2]/div[1]/div[4]/div[3]/table/tbody/tr/td[1]/a')
all_data.click()
years=browser.find_element_by_xpath('//*[@id="calBorder"]/span/table/tbody/tr[1]/td/table/tbody/tr/td[2]/select')
for i in range(len(years.find_elements_by_tag_name('option'))):
for j in range(12):
for z in range(31):
time=browser.find_element_by_xpath('//*[@id="ctl00_Content_RB_dtpick1_dpHours"]')
for x in range(len(time.find_elements_by_tag_name('option'))):
all_data=browser.find_element_by_xpath('//*[@id="aspnetForm"]/div[3]/div[2]/div[1]/div[4]/div[3]/table/tbody/tr/td[1]/a')
all_data.click()
sleep(0.3)
yearss = browser.find_element_by_xpath('//*[@id="calBorder"]/span/table/tbody/tr[1]/td/table/tbody/tr/td[2]/select')
sy = Select(yearss)
sy.select_by_index(i)
sleep(0.3)
months = browser.find_element_by_xpath('//*[@id="calBorder"]/span/table/tbody/tr[1]/td/table/tbody/tr/td[1]/select')
sm = Select(months)
sm.select_by_index(j)
sleep(0.3)
days=browser.find_element_by_xpath('//*[@id="calBorder"]/span/table/tbody/tr[3]/td/table/tbody/tr[2]/td[6]')
if 'bgcolor="white"'==None in days:
days.click()
sleep(0.3)
times=browser.find_element_by_xpath('//*[@id="ctl00_Content_RB_dtpick1_dpHours"]')
ti=Select(times)
ti.select_by_index(x)
sleep(0.3)
show=browser.find_element_by_xpath('//*[@id="ctl00_Content_RB_dtpick1_btnOk"]')
show.click()
sleep(0.3)
也許你可以嘗試建立網址youself,像http://rate.am/en/armenian-dram-exchange-rates/banks/non-cash/2017/06/15/13-15 – newlife
我不允許使用其他鏈接 –
您可能有興趣瞭解可以避免使用硒的需求,例如http://rate.am/en/armenian-dram-exchange-rates/banks/non-現金/ 2015/04/09/20-15。請注意,儘管在這個URL中存在'en',頁面仍然以非羅馬字母表(我假設爲亞美尼亞語)返回。你會這樣嗎? –