Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why import urlfetch from Google App Engines?

Here in Google App Engines I got this code that would help fetch an HTML code of any web page by its URL:

from google.appengine.api import urlfetch
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:
doSomethingWithResult(result.content)

I don't understand one thing here (among many other things, in fact) why it is suggested in this code to import urlfecth from google.appengine.api ? Does Python not have this command onits own?

like image 815
brilliant Avatar asked Dec 12 '09 10:12

brilliant


People also ask

What is importance of Google App Engine?

Google App Engine makes it easy to use the platform, which offers the flexibility to focus on other concurrent web applications and processes. The best part is that GAE automatically handles the traffic increase through patching, provisioning, and monitoring.

What is Google App Engine launcher?

Google App Engine (GAE) is a platform-as-a-service product that provides web app developers and enterprises with access to Google's scalable hosting and tier 1 internet service. GAE requires that applications be written in Java or Python, store data in Google Bigtable and use the Google query language.

What are the features of Google App Engine?

The main benefits of Google App Engine are: Open and familiar languages and tools: Users can build and deploy apps quickly using popular languages or bring their own language runtimes and frameworks, they can also manage resources from the command line, debug source code, and run API back ends easily.

Which programming environment is used for Google App Engine?

js, Java, Ruby, C#, Go, Python, or PHP. A fully managed environment lets you focus on code while App Engine manages infrastructure concerns. Use Cloud Monitoring and Cloud Logging to monitor the health and performance of your app and Cloud Debugger and Error Reporting to diagnose and fix bugs quickly.


1 Answers

Python has libraries such as urllib and httplib for fetching URLs, but on App Engine, all requests must go through the custom urlfetch library. App Engine includes stubs for urllib and httplib that cause them to use urlfetch internally, but if you have a choice, using urlfetch directly is more efficient and flexible.

like image 113
Nick Johnson Avatar answered Oct 13 '22 18:10

Nick Johnson