Skip to content

Instantly share code, notes, and snippets.

@gracece
Last active Dec 20, 2015
Embed
What would you like to do?
p.py
#!/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