import random import requests import operator from lxml import etree redlist = range(1, 34) bluelist = range(1, 13) myredballs = sorted(random.sample(redlist, 6)) myblueball = random.sample(bluelist,1) url = "http://datachart.500.com/ssq/history/newinc/history.php?start=00001&end=2021141" response = requests.get(url) response = response.text selector = etree.HTML(response) for i in selector.xpath('//tr[@class="t_tr1"]'): ? ? datetime = i.xpath('td/text()')[0] ? ? red = list(map(int,i.xpath('td/text()')[1:7])) ? ? blue = int(i.xpath('td/text()')[7]) ? ? if(operator.eq(myredballs,red)): ? ? ? ? print("您机选的这组号码已经中过头奖了,建议重选") print("机选号码:",myredballs," ",myblueball,"本组号码未曾中过头奖,祝您中奖")
|