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,901
  • 15
  • 50
  • 64

2 Answers2

5

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
  • 73,447
  • 11
  • 124
  • 153
0

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

jcollado
  • 39,419
  • 8
  • 102
  • 133