Changing a request to receive a message in python?

I have it -

en.wikipedia.org/w/api.php?action=login&lgname=user&lgpassword=password

But it doesn't work because it is a receive request. What would be the query version after that?

Hooray!

0


a source to share


3 answers


The variables for the POST request are in the HTTP headers, not in the URL. Check urllib .

edit: Try this (I got it from here ):



import urllib
import urllib2

url = 'en.wikipedia.org/w/api.php'
values = {'action' : 'login',
          'lgname' : 'user',
          'password' : 'password' }

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()

      

+3


a source


params = urllib.urlencode({'action' : 'login', 'lgname' : 'user', 'lgpassword' : 'password'})
response = urllib.urlopen("http://en.wikipedia.org/w/api.php", params)

      



information on urllib can be found here .

+2


a source


Since your sample is in PHP use $ _REQUEST, this contains the contents of both $ _GET and $ _POST.

0


a source







All Articles