I want to hit a URL from python in google app engine. Can any one please tell me how can i hit the URL using python in google app engine.
+5
A:
You can use the URLFetch API
from google.appengine.api import urlfetch
url = "http://www.google.com/"
result = urlfetch.fetch(url)
if result.status_code == 200:
doSomethingWithResult(result.content)
AutomatedTester
2009-08-05 13:34:23
I want to fetch this URL via GAE cron job. But I am getting failure.Can you please tell me How can I fetch this URL via cron job? As I cannot test this this from my local machine.
2009-08-06 05:26:34
We need more details than just "failure".
Nick Johnson
2009-08-06 08:33:29
can you give us the error that is returned
AutomatedTester
2009-08-06 08:34:28
A:
It always depends on post or get. urllib can post to a form somewhere else, if we want the rather tricky thing validate between different hashes (sha and md5)
import urllib
data = urllib.urlencode({"id" : str(d), "password" : self.request.POST['passwd'], "edit" : "edit"})
result = urlfetch.fetch(url="http://www..../Login.do",
payload=data,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
if result.content.find('loggedInOrYourInfo') > 0:
self.response.out.write("clear")
else:
self.response.out.write("wrong password ")
LarsOn
2009-08-11 01:20:52