【发布时间】:2011-12-04 17:54:10
【问题描述】:
我正在尝试向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.com/readability/GetReadabilityScores?format=json&text=%s' % text
request_url = urllib.quote_plus(request_url.encode('utf-8'))
# make request
j = json.load(urllib.urlopen(request_url))
我在最后一行得到了这个错误:
[Errno 2] 没有这样的文件或目录:'http://ipeirotis.appspot.com/readability/GetReadabilityScores?format=json&text=this+reminds+me+of+the+Dutch+2001a+caravan+full+ of+smoky+people+Auld+Lang+Syne'
但是,错误中的 URL 是有效的,并在您访问它时返回响应。如何对 URL 进行编码以便可以使用 urlopen?非常感谢。
【问题讨论】:
标签: python json urllib urlopen