刮JS子包内容时出现问题

2024-04-18 05:56:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我在抓取这个webpage的JavaScript内容时遇到问题。我一直在使用BeautifulSoup,这对JS抓取没有多大帮助,因为我只得到以下输出,而不是JS子页面的文本内容。你知道吗

... <!--Comp:(1365)--> <div class="com700_"> <script> $(document).ready(function(){ tb_show("Captcha","/cr/haestirettur/captcha.jsp?KeepThis=true&TB_iframe=true&height=200&width=300&modal=true","/cr/haestirettur/img/loadinganimation.gif"); }); </script> </div> <!--/Comp:(1365)--> ....

在这里我执行以下Python代码

from bs4 import BeautifulSoup as bsoup
import requests as rq

url = 'http://haestirettur.is/domar?nr=10915'
r = rq.get(url)

soup = bsoup(r.content, "lxml")
print soup

有什么好方法可以让我用Python收集子页面的内容吗? 谢谢!你知道吗


Tags: importdivtrueurl内容asjsscript