I am writing a Python web application and I plan to use Wikipedia in it. When you tried to download the URL code, I was able to get both Google and Facebook (via the Google App Engine services), but when I tried to get wikipedia.org, I got an exception. Can anyone confirm that Wikipedia is not accepting these types of page requests? How does Wikipedia distinguish between me and the user?
Code snippet (this is 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))
source share