gpt4 book ai didi

javascript - Python读取http : html page as seen in browser - with javascripts results

转载 作者:行者123 更新时间:2023-12-03 06:53:27 26 4
gpt4 key购买 nike

我能否获得在浏览器中看到的 http 页面 - 在 javascripts 运行后完全形成?无需提交数据并按下按钮。恕我直言,这是标准任务,我在哪里可以看到运行所有脚本并获取结果的示例?

通过:

u = urllib.request.urlopen('https://www.*')
data = u.read()

如果我选择在浏览器中查看源代码,我会看到所看到的页面。但是,当我检查页面上的元素时,我会看到代码如何扩展,例如:

<div class="js-events-container"></div>

扩展为:

<div class="js-events-container">    <table class="zebra noBorderTbl" style="width: 100%;">
<tbody><tr>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
...
</tr>
</tbody></table>
</div>

最佳答案

我在类名中看到js,它可能是javascript,我认为没有办法用urllib获取完整页面。您需要在 javascript 启动后拉取该站点。您将需要 selenium 或 phantomjs 来完成这项工作。

关于javascript - Python读取http : html page as seen in browser - with javascripts results,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37398718/

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