-
-
Save gracece/6045024 to your computer and use it in GitHub Desktop.
p.py
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 csv | |
def post(url,data): | |
"""for score post """ | |
req = urllib2.Request(url) | |
data = urllib.urlencode(data) | |
opener = urllib2.build_opener() | |
response = opener.open(req,data) | |
lnum = 0 | |
result ="" | |
for line in response: | |
lnum += 1 | |
if lnum == 81: | |
if(line.find('未能查到') != -1): | |
return "\nnot found!" | |
if(lnum >= 80) and (lnum <=83): | |
result +=line | |
return result | |
def main(): | |
"""main""" | |
postUrl ="http://120.197.89.132:8800/myExamWeb/wap/school/gaokao/loveHS!dispatcher.action" | |
mobileNo = "13800138000" | |
birthdayRange = ['9310','9311','9312','9401','9402','9403','9404','9405','9406',\ | |
'9407','9408','9409','9410','9411','9412','9501','9502','9503','9504','9505',\ | |
'9506','9507','9508','9509','9510','9511','9512','9601','9602','9603'] | |
reader = csv.reader(open("Book1.csv")) | |
for examReferenceNo,userName in reader: | |
print examReferenceNo | |
print userName | |
open("result.txt",'a+').write("\n"+examReferenceNo+userName+"\n") | |
for i in range(len(birthdayRange)): | |
print birthdayRange[i] | |
birthday = birthdayRange[i] | |
data = {'id':'14356B43-7F8B-4B00-BB13-F95841F33C46','userName':userName,'examReferenceNo':examReferenceNo,\ | |
'birthday':birthday,'mobileNo':mobileNo} | |
response = post(postUrl,data) | |
print response | |
open("result.txt",'a+').write(response) | |
open("result.txt",'a+').write('<p>' + birthday + '</p>\n') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment