如何获取 html 的范围 > td.a> python 中的 JavaScript 链接
我要创建一个小型python工具,用于selenium web表内容javascript链接,但我不太确定如何写?
https://bet.hkjc.com/racing/index.aspx?lang=en&date=2022-03-06&venue=ST&raceno=8
#horseTable >正文> tr> td>一个
for race in range(1, race_count+1):
driver.get( '.com' )
**
tbody = driver.find_elements_by_css_selector('[id="horseTable"] tbody')[0]
trs = tbody.find_elements_by_css_selector('tr')
tds = trs.find_elements_by_css_selector('#horseTable > tbody > tr > td > a')
**
*
tr_header = trs[0]
trs_body = trs[ 0 : -1 ]
tds_link = tds[0 : -1]
*
for td in tds:
row_header.append(td.text.strip() )
data = []
for tr in trs_body:
row = []
tds = tr.find_elements_by_css_selector('td')
for td in tds:
row.append( td.text.strip() )
data.append( row )
now = str(datetime.datetime.now())[0:19]
*
link = []
link = browser.find_element_by_xpath('#horseTable > tbody > tr > td > a')
link.click()
*
```
i web t to create a the small python tool, For selenium web table content javascript link,But i'm not quite sure how to write?
https://bet.hkjc.com/racing/index.aspx?lang=en&date=2022-03-06&venue=ST&raceno=8
#horseTable > tbody > tr > td > a
for race in range(1, race_count+1):
driver.get( '.com' )
**
tbody = driver.find_elements_by_css_selector('[id="horseTable"] tbody')[0]
trs = tbody.find_elements_by_css_selector('tr')
tds = trs.find_elements_by_css_selector('#horseTable > tbody > tr > td > a')
**
*
tr_header = trs[0]
trs_body = trs[ 0 : -1 ]
tds_link = tds[0 : -1]
*
for td in tds:
row_header.append(td.text.strip() )
data = []
for tr in trs_body:
row = []
tds = tr.find_elements_by_css_selector('td')
for td in tds:
row.append( td.text.strip() )
data.append( row )
now = str(datetime.datetime.now())[0:19]
*
link = []
link = browser.find_element_by_xpath('#horseTable > tbody > tr > td > a')
link.click()
*
```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论