urlopen

    2热度

    2回答

    让我们考虑一个大文件(〜100MB)。让我们考虑这个文件是基于行的(一个文本文件,相对较短的行~80个字符)。 如果我使用内置的open()/file()该文件将被加载到lazy manner。 I.E.如果我做aFile.readline()只有一个文件块将驻留在内存中。 urllib.urlopen()是否做了类似的事情(使用磁盘上的缓存)? urllib.urlopen().readline

    2热度

    3回答

    我想从下面的代码中的地址读取一些utf-8文件。它适用于其中的大部分,但对于某些文件,urllib2(和urllib)无法读取。 这里很明显的答案是第二个文件已损坏,但奇怪的是IE浏览器都读取了它们,而且完全没有问题。代码已经在XP和Linux上进行了测试,结果相同。任何消化? import urllib2 #This works: f=urllib2.urlopen("http://www.

    3热度

    2回答

    这段代码有什么问题? >>> from urllib.request import urlopen >>> for line in urlopen("http://google.com/"): print(line.decode("utf-8")) <!doctype html><html><head><meta http-equiv="content-type" conten

    2热度

    2回答

    我在Python中使用urllib和urllib2来打开和阅读网页,但有时,我得到的文本是不可读的。例如,如果我运行此: import urllib text = urllib.urlopen('http://tagger.steve.museum/steve/object/141913').read() print text 我得到一些不可读的文本。我看过这些帖子: Gibberish

    1热度

    2回答

    我想一些文字传递给该readability API像这样: text = 'this reminds me of the Dutch 2001a caravan full of smoky people Auld Lang Syne' # construct Readability Metrics API url request_url = 'http://ipeirotis.appspot.

    2热度

    1回答

    超时后没有终止在Python 2.4.4的urlopen调用,我使用urllib2.urlopen()请求资源。发出请求之前,我设置了超时: socket.setdefaulttimeout(10) (Python的这种版本太旧有内置的超时版本的urlopen()) 在大多数情况下,这似乎工作正常。但是,我遇到了一个只能根据请求挂起的服务器。在Chrome浏览器中,浏览器放弃需要将近5分钟,然

    0热度

    1回答

    所以我检索从一个网站的一些JSON数据,并使用标准的urlopen()从urllib2的: 代码: url = 'http://api.nytimes.com/svc/politics/v3/us/legislative/congress/senate/votes/2011-12-14/2011-12-14.json?api-key=%s' % (api_key,) print urlopen(

    2热度

    1回答

    我使用python urllib2.urlopen获取html内容,我得到一个gziped响应。 我可以设置标题,所以我会得到它不拉链? 我的代码 response = urlopen(url,None , TIMEOUT) html = response.read() # read html print html 为Tichodroma建议我试试这个 request = Request(

    3热度

    1回答

    我想使用Python urlopen获取html网站。 我收到此错误: HTTPError: HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop 代码: from urllib2 import Request request = Request(url) re

    4热度

    1回答

    我正在使用gevent预执行并发下载。 基于this例子是这样的代码: import gevent from gevent import monkey urls = ['https://www.djangoproject.com/','http://www.nytimes.com/','http://www.microsoft.com'] monkey.patch_all() impo