3

This code produces a POST request:

urllib2.urlopen("http://somedomain.com/", data)

I would like to produce a GET request - any ideas on how to do that?

Thanks for the help!

Andrew
  • 3,761
  • 15
  • 49
  • 63

2 Answers2

4

Try:

urllib2.urlopen("http://somedomain.com/?" + data)

[edited]

If you want to send xml/json/etc data in the body, use something like:

urllib2.urlopen("http://somedomain.com/?" + parameters, data)

This will use the POST method, but any "GET" parameters will also be available to your application.

Paulo Scardine
  • 67,824
  • 10
  • 122
  • 145
0

Alternatively, you also use requests that has a more explicit API:

jcollado
  • 37,681
  • 8
  • 99
  • 131