1

To be brief, I've basically found that executing certain strings in the address bar in my browser causes good things to happen for me. For instance: http://myip:myport/?CreateOrder=Create+New+Order creates a new order in my database.

I've used python to set the variables I want passed into that string, but don't know the correct vocab to be able to figure exactly how to get python to execute that string as if it were a browser.

Sorry for being ignorant. I'd appreciate any help

1

2 Answers 2

2

While I am not sure that I entirely understand the context of your question you can make URL requests in python using the urllib2 module, specifically look at the urlopen function.

Here is an example of how you could make the request you showed:

import urllib2

url_response = urllib2.urlopen('http://myip:myport/?CreateOrder=Create+New+Order')
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I'm just dumb --I knew how to store/open the url like that, but didn't even come to the realization that by doing this, python is indeed executing the command
1

You should check out the Requests module.

import requests

r = requests.get('http://httpbin.org/get', params={'foo': 'bar'})

print r.content

(httpbin.org is a nice service for debugging HTTP requests)

Result:

{
  "url": "http://httpbin.org/get?foo=bar",
  "headers": {
    "Content-Length": "",
    "Accept-Encoding": "identity, deflate, compress, gzip",
    "X-Forwarded-Port": "80",
    "Host": "httpbin.org",
    "Accept": "*/*",
    "User-Agent": "python-requests/0.8.3",
    "Connection": "keep-alive",
    "Content-Type": ""
  },
  "args": {
    "foo": "bar"
  },
  "origin": "46.64.26.143"
}

2 Comments

Nice site you mentioned for inspecting HTTP requests :)
Is there any version of this module for windows?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.