TypeError:'NoneType'对象不可迭代(selenium 2.49)

时间:2016-01-23 06:22:02

标签: python python-3.x selenium

所以,我正在尝试制作一个“用户友好”的自动刮刀。我基本上想要它做的是,刮一页,单击按钮,刮取该页面,单击按钮。并根据用户的需要设置该循环次数。 (是的,我知道缩进是关闭的,我正在测试一些东西。

Traceback (most recent call last):
  File "C:/Users/Skid/PycharmProjects/untitled/PureTest.py", line 34, in <module>
    NormalScrape()
  File "C:/Users/Skid/PycharmProjects/untitled/PureTest.py", line 31, in NormalScrape
    print(post.text)
  File "C:\Users\Skid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 71, in text
    return self._execute(Command.GET_ELEMENT_TEXT)['value']
  File "C:\Users\Skid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 454, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\Skid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Skid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: chrome=47.0.2526.111)
  (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 10.0 x86_64)

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x00F4DB10>>
Traceback (most recent call last):
  File "C:\Users\Skid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 136, in __del__
  File "C:\Users\Skid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 120, in stop
  File "C:\Users\Skid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 95, in send_remote_shutdown_command
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 887, in _find_spec
TypeError: 'NoneType' object is not iterable

错误:

that.nextQuestion()

1 个答案:

答案 0 :(得分:3)

这是 Selenium 2.49 + Python 3 + Chrome 中的现有错误:

作为解决方法,降级到2.48

pip3 install selenium==2.48