我想刮掉这个网站。
当我执行我的代码时,我遇到了问题。
这是我的代码。
Traceback (most recent call last):
File "D:/python code/auction_crawl/auction_crawler.py", line 36, in <module>
scraper.main_scrape()
File "D:/python code/auction_crawl/auction_crawler.py", line 27, in main_scrape
self.driver.find_element_by_id("pwd_dummy").send_keys('k1150719!!!')
File "C:\Users\Hyun Mo\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 347, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
File "C:\Users\Hyun Mo\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 491, in _execute
return self._parent.execute(command, params)
File "C:\Users\Hyun Mo\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 238, in execute
self.error_handler.check_response(response)
File "C:\Users\Hyun Mo\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element
(Session info: chrome=56.0.2924.87)
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64)
我收到了这个错误
#!/usr/bin/python
lenlist = 9
while lenlist <= 0:
print "hello"
lenlist -= 1
我该如何解决? 我会改变我的司机吗?或者我会搜索execute_script ??但我不懂javascript
答案 0 :(得分:1)
我解决了这个问题。
password = self.driver.find_element_by_id("pwd_dummy")
actions = webdriver.ActionChains(self.driver)
actions.move_to_element(password)
actions.click()
actions.send_keys("mypassword") # Replace with whichever keys you want.
actions.perform()
我使用上面的代码而不是代码。
self.driver.find_element_by_id("pwd_dummy").clear()
self.driver.find_element_by_id("pwd_dummy").send_keys('mypassword')