取每期双色球中奖号码

取每期双色球中奖号码

获取每期双色球中奖号码,便于观察,话不多说,代码如下

# -*- coding:utf-8 -*-
# __author__ :kusy
# __content__:获取每期双色球中奖号码
# __date__:2018/10/12 17:08
import urllib.request
import re class GetApiTxtByRegexp(object):
def __init__(self, url, regexp):
self.url = url
self.regexp = regexp def get_content(self):
page = urllib.request.urlopen(self.url)
content = page.read()
# print(content)
content_reg = re.compile(self.regexp)
list_content = re.findall(content_reg, content.decode('gbk'))
return list_content if __name__ == '__main__':
# 获取每期期号地址(暂时无法直接获取)
# url = 'http://kaijiang.500.com/shtml/ssq/18119.shtml?0_ala_baidu'
# regexp = r'' # url = 'http://kaijiang.500.com/shtml/ssq/18118.shtml'
regexp = r'<li class="ball_.*?">(\d*)</li>'
list_blue = []
for tikitno in range(18000, 18120, 1):
tikitno = str(tikitno)
url = 'http://kaijiang.500.com/shtml/ssq/' + tikitno + '.shtml'
try:
gettxt = GetApiTxtByRegexp(url, regexp)
list_content = gettxt.get_content()
list_blue.append(list_content[-1])
print(tikitno,'--',list_content)
except urllib.error.HTTPError:
pass # 获取各数字篮球出现的次数
list_cnt = [0] * 16
for blue in list_blue:
for i in range(1,17,1):
if int(blue) == i:
list_cnt[i-1] += 1
print(list_blue)
print(list_cnt)
d = dict(zip(list(range(1, 17, 1)), list_cnt))
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
# 篮球出现次数排序
print(d)

结果如下图

E:\kusy\future\venv\Scripts\python.exe E:/kusy/future/double_color_ball.py
18001 -- ['', '', '', '', '', '', '']
18002 -- ['', '', '', '', '', '', '']
18003 -- ['', '', '', '', '', '', '']
18004 -- ['', '', '', '', '', '', '']
18005 -- ['', '', '', '', '', '', '']
18006 -- ['', '', '', '', '', '', '']
18007 -- ['', '', '', '', '', '', '']
18008 -- ['', '', '', '', '', '', '']
18009 -- ['', '', '', '', '', '', '']
18010 -- ['', '', '', '', '', '', '']
18011 -- ['', '', '', '', '', '', '']
18012 -- ['', '', '', '', '', '', '']
18013 -- ['', '', '', '', '', '', '']
18014 -- ['', '', '', '', '', '', '']
18015 -- ['', '', '', '', '', '', '']
18016 -- ['', '', '', '', '', '', '']
18017 -- ['', '', '', '', '', '', '']
18018 -- ['', '', '', '', '', '', '']
18019 -- ['', '', '', '', '', '', '']
18020 -- ['', '', '', '', '', '', '']
18021 -- ['', '', '', '', '', '', '']
18022 -- ['', '', '', '', '', '', '']
18023 -- ['', '', '', '', '', '', '']
18024 -- ['', '', '', '', '', '', '']
18025 -- ['', '', '', '', '', '', '']
18026 -- ['', '', '', '', '', '', '']
18027 -- ['', '', '', '', '', '', '']
18028 -- ['', '', '', '', '', '', '']
18029 -- ['', '', '', '', '', '', '']
18030 -- ['', '', '', '', '', '', '']
18031 -- ['', '', '', '', '', '', '']
18032 -- ['', '', '', '', '', '', '']
18033 -- ['', '', '', '', '', '', '']
18034 -- ['', '', '', '', '', '', '']
18035 -- ['', '', '', '', '', '', '']
18036 -- ['', '', '', '', '', '', '']
18037 -- ['', '', '', '', '', '', '']
18038 -- ['', '', '', '', '', '', '']
18039 -- ['', '', '', '', '', '', '']
18040 -- ['', '', '', '', '', '', '']
18041 -- ['', '', '', '', '', '', '']
18042 -- ['', '', '', '', '', '', '']
18043 -- ['', '', '', '', '', '', '']
18044 -- ['', '', '', '', '', '', '']
18045 -- ['', '', '', '', '', '', '']
18046 -- ['', '', '', '', '', '', '']
18047 -- ['', '', '', '', '', '', '']
18048 -- ['', '', '', '', '', '', '']
18049 -- ['', '', '', '', '', '', '']
18050 -- ['', '', '', '', '', '', '']
18051 -- ['', '', '', '', '', '', '']
18052 -- ['', '', '', '', '', '', '']
18053 -- ['', '', '', '', '', '', '']
18054 -- ['', '', '', '', '', '', '']
18055 -- ['', '', '', '', '', '', '']
18056 -- ['', '', '', '', '', '', '']
18057 -- ['', '', '', '', '', '', '']
18058 -- ['', '', '', '', '', '', '']
18059 -- ['', '', '', '', '', '', '']
18060 -- ['', '', '', '', '', '', '']
18061 -- ['', '', '', '', '', '', '']
18062 -- ['', '', '', '', '', '', '']
18063 -- ['', '', '', '', '', '', '']
18064 -- ['', '', '', '', '', '', '']
18065 -- ['', '', '', '', '', '', '']
18066 -- ['', '', '', '', '', '', '']
18067 -- ['', '', '', '', '', '', '']
18068 -- ['', '', '', '', '', '', '']
18069 -- ['', '', '', '', '', '', '']
18070 -- ['', '', '', '', '', '', '']
18071 -- ['', '', '', '', '', '', '']
18072 -- ['', '', '', '', '', '', '']
18073 -- ['', '', '', '', '', '', '']
18074 -- ['', '', '', '', '', '', '']
18075 -- ['', '', '', '', '', '', '']
18076 -- ['', '', '', '', '', '', '']
18077 -- ['', '', '', '', '', '', '']
18078 -- ['', '', '', '', '', '', '']
18079 -- ['', '', '', '', '', '', '']
18080 -- ['', '', '', '', '', '', '']
18081 -- ['', '', '', '', '', '', '']
18082 -- ['', '', '', '', '', '', '']
18083 -- ['', '', '', '', '', '', '']
18084 -- ['', '', '', '', '', '', '']
18085 -- ['', '', '', '', '', '', '']
18086 -- ['', '', '', '', '', '', '']
18087 -- ['', '', '', '', '', '', '']
18088 -- ['', '', '', '', '', '', '']
18089 -- ['', '', '', '', '', '', '']
18090 -- ['', '', '', '', '', '', '']
18091 -- ['', '', '', '', '', '', '']
18092 -- ['', '', '', '', '', '', '']
18093 -- ['', '', '', '', '', '', '']
18094 -- ['', '', '', '', '', '', '']
18095 -- ['', '', '', '', '', '', '']
18096 -- ['', '', '', '', '', '', '']
18097 -- ['', '', '', '', '', '', '']
18098 -- ['', '', '', '', '', '', '']
18099 -- ['', '', '', '', '', '', '']
18100 -- ['', '', '', '', '', '', '']
18101 -- ['', '', '', '', '', '', '']
18102 -- ['', '', '', '', '', '', '']
18103 -- ['', '', '', '', '', '', '']
18104 -- ['', '', '', '', '', '', '']
18105 -- ['', '', '', '', '', '', '']
18106 -- ['', '', '', '', '', '', '']
18107 -- ['', '', '', '', '', '', '']
18108 -- ['', '', '', '', '', '', '']
18109 -- ['', '', '', '', '', '', '']
18110 -- ['', '', '', '', '', '', '']
18111 -- ['', '', '', '', '', '', '']
18112 -- ['', '', '', '', '', '', '']
18113 -- ['', '', '', '', '', '', '']
18114 -- ['', '', '', '', '', '', '']
18115 -- ['', '', '', '', '', '', '']
18116 -- ['', '', '', '', '', '', '']
18117 -- ['', '', '', '', '', '', '']
18118 -- ['', '', '', '', '', '', '']
18119 -- ['', '', '', '', '', '', '']
['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
[7, 6, 10, 6, 8, 8, 13, 2, 8, 7, 7, 9, 7, 7, 5, 9]
[(7, 13), (3, 10), (12, 9), (16, 9), (5, 8), (6, 8), (9, 8), (1, 7), (10, 7), (11, 7), (13, 7), (14, 7), (2, 6), (4, 6), (15, 5), (8, 2)] Process finished with exit code 0
05-11 21:57