我在玩,想给自己发一封电子邮件时,在论坛上出现了一个新帖子,但当我打开网址时urllib.urlopen我得到了网页,但没有网页正文。有人能告诉我为什么会这样吗?我怎样才能得到尸体?在
def loadUrl(adress):
adress = urllib.unquote(adress)
print("Loading " + adress)
socket =urllib.urlopen(adress)
html = socket.read()
socket.close()
soup = BeautifulSoup(html)
return soup
soup = loadUrl("http://de.pokerstrategy.com/forum/thread.php?threadid=498111")
编辑对不起,我不知道你已经发布了你想要检索的网址。我得到的答复和你一样,但不知道为什么。我在javascript中看不到任何东西,正如我在下面建议的那样。在
我测试了你的代码,它似乎运行得很好。可能您尝试检索的页面通过javascript或类似的方式生成body元素。在本例中,我相信您可以使用selenium之类的东西来模拟浏览器。在
另外,我建议使用Pyquery。在
我已经成功地将
BeautifulSoup
与urllib2
结合使用,例如:相关问题 更多 >
编程相关推荐