【发布时间】:2022-01-24 03:19:44
【问题描述】:
作为游泳者,我正在尝试从用户输入姓名或其他可选字段后可以访问的表中提取时间。该网站动态生成此数据。以下是我当前的代码,不考虑用户输入。
我对 selenium 的自动化工作原理以及如何为其找到正确的文本字段以读取我的结果以及我的其余代码以提取表格感到非常困惑。
谁能提供一些关于如何进行的建议?
任何帮助表示赞赏并提前致谢。
这是我当前的代码:
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
site = 'https://www.swimming.org.nz/results.html'
wd = webdriver.Chrome( "C:\\Users\\joseph\\webscrape\\chromedriver.exe")
wd.get(site)
html = wd.page_source
df = pd.read_html(html)
df[1].to_csv('Results.csv')
【问题讨论】:
标签: selenium web-scraping xpath iframe css-selectors