0

我正在使用以下python代码:

def get_data(self, url):
    usock = urllib2.urlopen(url)
    data = usock.read()
    usock.close()
    return data

To parse data from a certain website and it worked for a while. Now something went wrong.
When I use this function now it gives me a source code but different than the one there is when you open the view-source:url
I am using chrome for the regular website view. Is there a way to get the same source code as I see by using the "view source" option? thanks.

4

1 回答 1

0

我不使用 Chrome,但是否可以“查看源代码”显示源代码,包括 JavaScript 生成的内容?而您的 Python 代码返回“原始”内容。

请注意,某些网站会根据客户端(以及它的假定功能)返回不同的内容。

所有这些都是推测性的,为了“公平”比较,您可以将您的结果与使用wgetor获得的结果进行比较curl

于 2013-06-11T05:59:47.207 回答