fill splinter 延迟,Python Splinter从表中获取价值(后续同级)

Given this code ("sleep" instances used to help display what's going on):

from splinter import Browser

import time

with Browser() as browser:

# Visit URL

url = "https://mdoe.state.mi.us/moecs/PublicCredentialSearch.aspx"

browser.visit(url)

browser.fill('ctl00$ContentPlaceHolder1$txtCredentialNumber', 'IF0000000262422')

# Find and click the 'search' button

button = browser.find_by_name('ctl00$ContentPlaceHolder1$btnSearch')

# Interact with elements

button.first.click()

time.sleep(5)

#Only click the link next to "Professional Teaching Certificate Renewal"

certificate_link = browser.find_by_xpath("//td[. = 'Professional Teaching Certificate Renewal']/following-sibling::td/a")

certificate_link.first.click()

time.sleep(10)

I am now trying to get the values from the table that shows after this code runs. I am not well-versed in xpath commands, but based on the response to this question, I have tried these, to no avail:

name = browser.find_by_xpath("//td[. ='Name']/following-sibling::td/a")

name = browser.find_by_xpath("//td[. ='Name']/following-sibling::td/[1]")

name = browser.find_by_xpath("//td[. ='Name']/following-sibling::td/[2]")

I tried [2] because I do notice a colon (:) sibling character between "Name" and the cell containing the name. I just want the string value of the name itself (and all other values in the table).

I do notice a different structure (span is used within td instead of just td) in this case (I also tried td span[. ='Name']... but no dice):

Updated to show more detail

Name

:

MICHAEL WILLIAM LANCE

解决方案

This ended up working:

browser.find_by_xpath("//td[span='Name']/following-sibling::td")[1].value

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值