Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行报错:element is not attached to the page document #30

Open
Con-Ming opened this issue Apr 29, 2022 · 0 comments
Open

运行报错:element is not attached to the page document #30

Con-Ming opened this issue Apr 29, 2022 · 0 comments

Comments

@Con-Ming
Copy link

Traceback (most recent call last):
File "D:/MyPythonProject/weibo-topic-spider-master/super-topic-spyder.py", line 97, in get_all_text
weibo_content = driver.find_element(By.CLASS_NAME,'weibo-text').text
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1250, in find_element
'value': value})['value']
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".weibo-text"}
(Session info: headless chrome=100.0.4896.127)
Stacktrace:
Backtrace:
Ordinal0 [0x007E7413+2389011]
Ordinal0 [0x00779F61+1941345]
Ordinal0 [0x0066C658+837208]
Ordinal0 [0x006991DD+1020381]
Ordinal0 [0x0069949B+1021083]
Ordinal0 [0x006C6032+1204274]
Ordinal0 [0x006B4194+1130900]
Ordinal0 [0x006C4302+1196802]
Ordinal0 [0x006B3F66+1130342]
Ordinal0 [0x0068E546+976198]
Ordinal0 [0x0068F456+980054]
GetHandleVerifier [0x00999632+1727522]
GetHandleVerifier [0x00A4BA4D+2457661]
GetHandleVerifier [0x0087EB81+569713]
GetHandleVerifier [0x0087DD76+566118]
Ordinal0 [0x00780B2B+1968939]
Ordinal0 [0x00785988+1989000]
Ordinal0 [0x00785A75+1989237]
Ordinal0 [0x0078ECB1+2026673]
BaseThreadInitThunk [0x75DEFA29+25]
RtlGetAppContainerNamedObjectPath [0x77B47A7E+286]
RtlGetAppContainerNamedObjectPath [0x77B47A4E+238]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:/MyPythonProject/weibo-topic-spider-master/super-topic-spyder.py", line 270, in
spider(username,password,book_name_xls,sheet_name_xls,keyword,maxWeibo,num,save_pic)
File "D:/MyPythonProject/weibo-topic-spider-master/super-topic-spyder.py", line 249, in spider
get_current_weibo_data(elems,book_name_xls,name,yuedu,taolun,maxWeibo,num) #爬取实时
File "D:/MyPythonProject/weibo-topic-spider-master/super-topic-spyder.py", line 157, in get_current_weibo_data
insert_data(elems,book_name_xls,name,yuedu,taolun,num,save_pic)
File "D:/MyPythonProject/weibo-topic-spider-master/super-topic-spyder.py", line 57, in insert_data
weibo_content = get_all_text(elem)
File "D:/MyPythonProject/weibo-topic-spider-master/super-topic-spyder.py", line 101, in get_all_text
weibo_content = elem.find_elements(By.CSS_SELECTOR,'div.weibo-text')[0].text
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 762, in find_elements
{"using": by, "value": value})['value']
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 710, in _execute
return self._parent.execute(command, params)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, 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: headless chrome=100.0.4896.127)
Stacktrace:
Backtrace:
Ordinal0 [0x007E7413+2389011]
Ordinal0 [0x00779F61+1941345]
Ordinal0 [0x0066C658+837208]
Ordinal0 [0x0066F064+847972]
Ordinal0 [0x0066EF22+847650]
Ordinal0 [0x0066F1B0+848304]
Ordinal0 [0x00698EF2+1019634]
Ordinal0 [0x0069949B+1021083]
Ordinal0 [0x0068FE51+982609]
Ordinal0 [0x006B4194+1130900]
Ordinal0 [0x0068F974+981364]
Ordinal0 [0x006B4364+1131364]
Ordinal0 [0x006C4302+1196802]
Ordinal0 [0x006B3F66+1130342]
Ordinal0 [0x0068E546+976198]
Ordinal0 [0x0068F456+980054]
GetHandleVerifier [0x00999632+1727522]
GetHandleVerifier [0x00A4BA4D+2457661]
GetHandleVerifier [0x0087EB81+569713]
GetHandleVerifier [0x0087DD76+566118]
Ordinal0 [0x00780B2B+1968939]
Ordinal0 [0x00785988+1989000]
Ordinal0 [0x00785A75+1989237]
Ordinal0 [0x0078ECB1+2026673]
BaseThreadInitThunk [0x75DEFA29+25]
RtlGetAppContainerNamedObjectPath [0x77B47A7E+286]
RtlGetAppContainerNamedObjectPath [0x77B47A4E+238]

麻烦你看一下,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant