简体   繁体   中英

What is the difference between html-text by “view source code” on Internet Explorer and by requests.get() method in python?

For example,

"view source code" on Internet Explorer → <html> aaa(bbb)ccc </html>

requests.get(url).text<html> aaa()ccc </html>

Why?

How I can get the former html-text in Python?

This can be explained by several reasons:

  • Either the website filters the clients by a criterion (like the User Agent header) so it only sends the contents to "real" clients (ie browsers)

  • Either the website loads an empty webpage and then populates it with javascript, which means that you only get the dummy page with your GET request (this can only be the case if you use Inspect Element and not View source code )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM