NoSuchElementException: Message: Unable to locate element:

python crawler

Error occurs when trying to find an element with selenium

The reason 1: xpath wrong path

    The solution is to modify the path xpath

Reason 2: selenium page did not load completely, it is not locked to the element

    The solution is to use sleep function, wait for some time, so the page can be loaded completely

 browser.get("https://gkcx.eol.cn/school/search?province=%E6%B9%96%E5%8D%97")
 time.sleep(2)
browser.find_element_by_xpath("......").click()

 

Guess you like

Origin www.cnblogs.com/cttcarrotsgarden/p/11210883.html