我有两个文件main.py和test.py 我需要从Soccerway报废数据,但首先我需要输入日期示例2011/2012或范围从2011/2019 我该如何解决
main.py
date = input ("Insert Date: ")
test.py
from time import sleep
from urllib.parse import urlparse
from scraper import scrape_match
from write_to_spread import write_spread
from season import get_urls_season
driver = webdriver.Chrome()
driver.fullscreen_window()
driver.get("https://us.soccerway.com" + url_path)
click_privacy_policy(driver)
driver.find_element_by_xpath("//select[@name='season_id']/option[text('how can input date')]").click()
我需要输入日期,例如2018/2019并输入该日期,或者输入2010-2019并输入每个页面
答案 0 :(得分:0)
接受输入和split
的输入以获取开始和结束年份并进行字符串操作,它将在您照看时单击。
inptdate='2010-2019'
startdate=inptdate.split('-')[0]
enddate=inptdate.split('-')[1]
while int(startdate)<int(enddate):
textstring=str(startdate) + "/" + str(int(startdate)+1)
print(textstring)
driver.find_element_by_xpath("//select[@name='season_id']/option[text()='" + textstring +"']").click()
startdate=int(startdate)+1