import requests import xlrd import xlwt import tkinter data=xlrd.open_workbook('C:/1.xlsx') table = data.sheets()[0] #table = data.sheet_by_name(u'Sheet1') ncol=table.ncols nrow=table.nrows #row_value=table.cell(0,1) value=table.cell(0,0).value print(ncol,nrow) def getksh(self): for i in range(0,ncol): ksh=table.cell(0,i).value print(ksh) url1='http://cx.ahzsks.cn/pugao/pgcj2018_in.php' s=requests.Session() r=s.get(url1) cookies=r.cookies.get_dict() #print(cookies) yzm=str(r.content).split(sep='maxlength="4"/>')[1][:4] print(yzm) headers={ "Accept":" text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding":"gzip,deflate", "Accept-Language": "zh-CN,zh;q=0.9", "Cache-Control": "max-age=0", "Connection": "keep-alive", "Cookie": "PHPSESSID=ivff7mb3uls4qtov3c6levh6d7", "Host": "cx.ahzsks.cn", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3452.0 Safari/537.36" } data={"ksh":ksh,'sfzh':sfzh,"yzm":yzm}