the from requests_html import HTMLSession, HTMLResponse
The session=HTMLSession ()
The response=session. Get (' http://www.baidu.com ')
Print (response. HTML. The links)
Will PyCharm line 4 statements "HTML" standard yellow, PyCharm don't think the response object HTML field, the cursor to the get () method to check the method signature, found that the return type is the response, and this class does not HTML field,
But the code can be run, this shows that the response object actually have HTML field, then guess the response actually is requests_html HTMLResponse type, change the line 3 code to:
response: HTMLResponse=session. Get (' http://www.baidu.com ')
4 lines of code in the "HTML" no longer is yellow, but the third line "session. Get (' http://www.baidu.com ')" has now become a yellow, PyCharm perceive HTMLSession. The return type of the get () and the type of the response do not match,
See a circle of the source code, HTMLSession defined class does not get () method, it has inherited the indirect requests. The Session classes, the get () method is inherited from the Session class, but why the Session. The return type is the Response of the get (), and HTMLSession. The get () the actual return type is HTMLResponse?