gpt4 book ai didi

python - Jupyter requests.get 返回不完整的 html

转载 作者:行者123 更新时间:2023-12-01 09:06:58 24 4
gpt4 key购买 nike

我在 Jupyter Notebook 中运行以下 Python 代码,但返回不完整的 html。

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

然后我在VS code中运行,返回的是完整的html

我想知道原因,以及如何在Jupyter中返回完整的html。

谢谢。

最佳答案

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

在 jupyter 中尝试一下。为什么?因为jupyter中的机制。

原因是js加载了东西。你可以在第53行和第61行找到一些东西。你可以用Chrome调试,你可以找到

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

}

你可以自己尝试一下,喜欢就好。

enter image description here

希望有帮助。

关于python - Jupyter requests.get 返回不完整的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51968109/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com