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

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

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]".

  1. def ClientInformation():
  2. # CI = textbox.get('1.0', END)
  3. CI = "first name, Last Name"
  4. city = "City, State"
  5. options = Options()
  6. options.add_experimental_option("detach", True)
  7. # Installs and Opens Chrome to "Truepeoplesearch.com"
  8. driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
  9. options=options)
  10. driver.get("https://www.truepeoplesearch.com/")
  11. # Enters data from UI to text fields and searches
  12. driver.find_element(by="name", value="CityStateZip").send_keys(city)
  13. driver.find_element(by="name", value="Name").send_keys(CI)
  14. if len(driver.find_elements("xpath", "//a[@herf]")) > 0:
  15. driver.find_elements("xpath","//a[@herf]")[0].click()
  16. else:
  17. print("you suck")

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

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

solved

  1. CI = textbox.get('1.0', END)
  2. # Split Client Information by " : "
  3. CIS = re.split(r' ', str(CI))
  4. FN = CIS[0]
  5. LN = CIS[1]
  6. CT = CIS[2]
  7. ST = CIS[3]
  8. 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]".

  1. def ClientInformation():
  2. #CI = textbox.get('1.0', END)
  3. CI = "first name, Last Name"
  4. city = "City, State"
  5. options = Options()
  6. options.add_experimental_option("detach", True)
  7. #Installs and Opens Chrome to "Truepeoplesearch.com"
  8. driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
  9. options=options)
  10. driver.get("https://www.truepeoplesearch.com/")
  11. #Enters data from UI to text fields and searches
  12. driver.find_element(by="name", value="CityStateZip").send_keys(city)
  13. driver.find_element(by="name", value="Name").send_keys(CI)
  14. if len(driver.find_elements("xpath", "//a[@herf]")) > 0:
  15. driver.find_elements("xpath","//a[@herf]")[0].click()
  16. else:
  17. print("you suck")

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

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

solved

  1. CI = textbox.get('1.0', END)
  2. #Split Client Information by " : "
  3. CIS = re.split(r' ', str(CI))
  4. FN = CIS[0]
  5. LN = CIS[1]
  6. CT = CIS[2]
  7. ST = CIS[3]
  8. 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:

确定