【发布时间】:2021-11-24 23:07:15
【问题描述】:
我对此感到困惑。Python 代码用于使用通配符* 循环遍历 url,该通配符仅替换每个匹配项的唯一 ID。这个 url 模式http://www.sportal.de/fussball/bundesliga/spielernoten-bayern-muenchen-fc-schalke-04-1-spieltag-2020-2021-20138500 的问题在于,要使用通配符的文本位于 url 的不变部分和 id 之间。我是编码宇宙的新手,非常感谢任何帮助。完整代码为here
from time import sleep
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import pandas as pd
errors = []
season = []
for id in range(20138500, 20138501):
# Opening the connection and grabbing the page
my_url = f'http://www.sportal.de/fussball/bundesliga/spielernoten*{id}'
option = Options()
option.headless = False
driver = webdriver.Firefox(options=option)
driver.get(my_url)
【问题讨论】:
标签: python selenium url wildcard