The import requests_html
The session=requests_html. HTMLSession ()
R=session. Get (' https://www.baidu.com/')
Print (r.t ext)
Error:
Traceback (the most recent call last) :
The File "C:/Users/41621/PyCharmEdu2018.3/config/scratches/ht/ht001 py", line 3, the in & lt; module>
R=session. Get (' https://www.baidu.com/')
The File "C: \ Users \ \ AppData \ 41621 Local \ designed \ Python \ Python37 \ lib \ site - packages \ requests \ sessions py", line 543, in the get
Return the self. The request (' GET 'url, * * kwargs)
The File "C: \ Users \ \ AppData \ 41621 Local \ designed \ Python \ Python37 \ lib \ site - packages \ requests \ sessions py", line 530, in the request
Resp=self. Send (prep, * * send_kwargs)
The File "C: \ Users \ \ AppData \ 41621 Local \ designed \ Python \ Python37 \ lib \ site - packages \ requests \ sessions py", line 650, in the send
R=dispatch_hook (' response, hooks, r, * * kwargs)
File "C: \ Users \ \ AppData \ 41621 Local \ designed \ Python \ Python37 \ lib \ site - packages \ requests \ hooks py", 31, the line in dispatch_hook
_hook_data=https://bbs.csdn.net/topics/hook (hook_data, * * kwargs)
The File "C: \ Users \ 41621 \ AppData \ \ Roaming \ Python Python37 \ site - packages \ requests_html py", line 709, in response_hook
Return HTMLResponse. _from_response (the response, the self)
The File "C: \ Users \ 41621 \ AppData \ \ Roaming \ Python Python37 \ site - packages \ requests_html py", line 660, in _from_response
Html_r=CLS (session=session)
The File "C: \ Users \ 41621 \ AppData \ \ Roaming \ Python Python37 \ site - packages \ requests_html py", line 647, in __init__
Super (HTMLResponse, self) __init__ ()
The File "C: \ Users \ \ AppData \ 41621 Local \ designed \ Python \ Python37 \ lib \ site - packages \ requests \ models py", line 598, in __init__
The self. The HTML=None
AttributeError: can 't set the attribute
The Process finished with exit code 1
Just began to learn, a great god, please give help to reassure, appreciate,
CodePudding user response:
The self. The HTML=NoneAttributeError: can 't set the attribute
HTML=None that should be nothing to climb to the
Why do you have to use requests_html
Requests + bs4 is not very complicated