How can I send raw post data with python?
I'm trying to post data to a web page using python. There is a game on facebook, and the invite codes are combinations of 5 letters. I wrote a script that wrote all the combinat开发者_如何学JAVAions of letters to a txt file.
Here is the data I need to post. http://pastie.org/2409481
This cookie 'bbbbb' will end up being a variable and will loop through all the possible combinations of 5 letters. [code]invite_code%5D=bbbbb[/code]
Take a look at Requests, a wrapper for urllib2 (I believe). Ripping one of the examples off that page:
# This example cooked up by me!
import requests
post_data = {"amount":10000, "service":"writing blog posts"}
r = requests.post('http://example.com/api', post_data, auth=('user', 'pass'))
print r.status_code
print r.headers['content-type']
# ------
# 200
# 'application/json'
You should be able to set anything you want for post_data
.
精彩评论