【发布时间】:2020-08-17 13:32:43
【问题描述】:
我会从这个页面上刮掉 ID https://www.flashscore.co.uk/football/russia/premier-league/results/
然后将 g_1_替换为https://www.flashscore.com/match/ 并将这些url导入txt文件。
我用过这段代码
matches=WebDriverWait(driver, 5).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[starts-with(@id,'g_1_')]")))
for match in matches:
g1 = matches.replace("g_1_", "https://www.flashscore.com/match/")
print(g1)
但我得到了这个错误
AttributeError: 'list' object has no attribute 'replace'
【问题讨论】:
-
你有一个错字。应该是
g1 = match.replace("g_1_", "https://www.flashscore.com/match/");不是matches.replace()
标签: python selenium xpath web-scraping