标签:分享 lib book get result for main work request
# -*- coding: UTF-8 -*-
# author
# http test
import urllib,urllib2
import xlwt,xlrd
from xlutils.copy import copy
def post(url, data_):
# data_ = urllib.urlencode(data)
req = urllib2.Request(url)
req.add_data(data_)
res = urllib2.urlopen(req)
return res.read()
def main():
fname="h:\python\shuju\jiekou.xls"
book=xlrd.open_workbook(fname)
sheet=book.sheet_by_name("Sheet1")
wb=copy(book)
rows=sheet.nrows
case_list=[]
for i in range(1,rows):
url=sheet.cell_value(i,2)
data=sheet.cell_value(i,3)
result=post(url,data)
qiwang=sheet.cell_value(i,4)
#第6列写结果
if qiwang in result:
wb.get_sheet(0).write(i,5,"pass")
wb.save(fname)
if __name__ == ‘__main__‘:
main()
excel模版
标签:分享 lib book get result for main work request
原文地址:http://www.cnblogs.com/wlyd/p/6025943.html