mkrecny
mkrecny

Reputation: 503

Python: how to make HTTP request internally/localhost

I want to send some parameters from a python script on my server to a php script on my server using HTTP. Suggestions?

Upvotes: 1

Views: 8647

Answers (1)

jathanism
jathanism

Reputation: 33726

This is pretty easy using urllib:

import urllib

myurl = 'http://localhost/script.php?var1=foo&var2=bar'

# GET is the default action
response = urllib.urlopen(myurl)  

# Output from the GET assuming response code was 200
data = response.read()            

Upvotes: 2

Related Questions