相关疑难解决方法(0)

维基百科是否允许通过Google App Engine获取URL?

我正在编写一个Python Web应用程序,其中我计划利用Wikipedia.在尝试一些URL提取代码时,我能够同时获取Google和Facebook(通过Google App Engine服务),但当我尝试获取wikipedia.org时,我收到了一个例外.任何人都可以确认维基百科不接受这些类型的页面请求吗?维基百科如何区分我和用户?

代码片段(它是Python!):

    import os
import urllib2
from google.appengine.ext.webapp import template


class MainHandler(webapp.RequestHandler):
    def get(self):
        url = "http://wikipedia.org"
        try:
          result = urllib2.urlopen(url)
        except urllib2.URLError, e:
          result = 'ahh the sky is falling'
        template_values= {
            'test':result,
        }
        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))
Run Code Online (Sandbox Code Playgroud)

python url google-app-engine web-applications http

4
推荐指数
1
解决办法
346
查看次数

标签 统计

google-app-engine ×1

http ×1

python ×1

url ×1

web-applications ×1