点击搜索人名后,我的目标是点击“查看详情”按钮。

huangapple go评论81阅读模式
英文:

My goal is to click on the view details button after searching for the persons name

问题

Whenever the search button is pressed, the webpage generates a new instance; however, my program is not reading the new instance, so it is not finding the correct "//a[@herf]".

def ClientInformation():
    # CI = textbox.get('1.0', END)
    CI = "first name, Last Name"
    city = "City, State"
    options = Options()
    options.add_experimental_option("detach", True)
    

    # Installs and Opens Chrome to "Truepeoplesearch.com"
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
                              options=options)
    driver.get("https://www.truepeoplesearch.com/")
    # Enters data from UI to text fields and searches
    driver.find_element(by="name", value="CityStateZip").send_keys(city)
    driver.find_element(by="name", value="Name").send_keys(CI)
    if len(driver.find_elements("xpath", "//a[@herf]")) > 0:
        driver.find_elements("xpath","//a[@herf]")[0].click()
    else:
        print("you suck")

It always prints "you suck" 点击搜索人名后,我的目标是点击“查看详情”按钮。

^^^^^^^ Doesn't work as well as I intended vvvvvvvvvvv new iteration

solved

CI = textbox.get('1.0', END)
# Split Client Information by " : "
CIS = re.split(r' ', str(CI))

FN = CIS[0]
LN = CIS[1]
CT = CIS[2]
ST = CIS[3]

driver.get("https://www.truepeoplesearch.com/results?name=" + FN + "%20" + LN +"&citystatezip= " + CT + " %20" + ST + "")
英文:

Whenever the search button is pressed the webpage generates a new instance however my program is not reading the new instance so it is not finding the correct "//a[@herf]".

def ClientInformation():
    #CI = textbox.get('1.0', END)
    CI = "first name, Last Name"
    city = "City, State"
    options = Options()
    options.add_experimental_option("detach", True)
    

    #Installs and Opens Chrome to "Truepeoplesearch.com"
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
                              options=options)
    driver.get("https://www.truepeoplesearch.com/")
    #Enters data from UI to text fields and searches
    driver.find_element(by="name", value="CityStateZip").send_keys(city)
    driver.find_element(by="name", value="Name").send_keys(CI)
    if len(driver.find_elements("xpath", "//a[@herf]")) > 0:
        driver.find_elements("xpath","//a[@herf]")[0].click()
    else:
        print("you suck")

It always prints you suck 点击搜索人名后,我的目标是点击“查看详情”按钮。

^^^^^^^ Doesn't work as well as I intended vvvvvvvvvvv new iteration

solved

CI = textbox.get('1.0', END)
    #Split Client Information by " : "
    CIS = re.split(r' ', str(CI))

    FN = CIS[0]
    LN = CIS[1]
    CT = CIS[2]
    ST = CIS[3]

driver.get("https://www.truepeoplesearch.com/results?name=" + FN + "%20" + LN +"&citystatezip= " + CT + " %20" + ST + "")

答案1

得分: 1

The site is blocking me so I can't test your script, but I would guess that you have a typo in there, and ("xpath","//a[@herf]") should instead read ("xpath","//a[@href]").

英文:

The site is blocking me so I can't test your script, but I would guess that you have a typo in there, and ("xpath","//a[@herf]") should instead read ("xpath","//a[@href]")

huangapple
  • 本文由 发表于 2023年6月13日 01:36:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76459052.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定