Created
January 14, 2015 02:43
-
-
Save liyaodong/4240f6f16c3e4bee0f27 to your computer and use it in GitHub Desktop.
python模拟post脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding=utf-8 | |
import urllib | |
import urllib2 | |
import random | |
def post(url, data): | |
req = urllib2.Request(url) | |
data = urllib.urlencode(data) | |
#enable cookie if need | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) | |
response = opener.open(req, data) | |
return response.read() | |
def main(): | |
posturl = "your post url" | |
counter = 0 | |
while counter < 20: | |
fp = random.randint(3000000000, 4000000000) | |
vote(fp, posturl) | |
counter += 1 | |
def vote(fp, posturl): | |
data = {'contentId': '826', 'fp': fp, 'mid':'5293e58e-043f-41a8-bec2-898559af69f5.flv'} | |
print post(posturl, data) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment