简体   繁体   中英

Jupyter requests.get returns incomplete html

I run the below python code in Jupyter notebook, but return an incomplete html.

import requests 
if __name__ == '__main__':
    target = 'http://www.biqukan.com/1_1094/5403177.html'
    req = requests.get(url=target)
    print(req.text)

Then I run it in VS code, the return is complete html

I want to know the reason, and how to return a complete html in Jupyter.

Thanks.

import requests 
target = 'http://www.biqukan.com/1_1094/5403177.html'
req = requests.get(url=target)
req.text

Try it in jupyter. Why is it? Because the mechanism in jupyter.

The reason is that there is something loaded by js. You can find something in line 53 and line 61. You can debug with Chrome, you can find

function read1(){
document.writeln("<div align=center style=\"margin-bottom:8px;\"><script src=\'http://www.biquge.lu/ads/kan_hf.js\'></script></div>");

}

You can try it by yourself, just like it.

在此处输入图片说明

Hope helpful.

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