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,581
  • 14
  • 46
  • 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
  • 60,096
  • 9
  • 116
  • 138
0

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

jcollado
  • 35,754
  • 6
  • 94
  • 129