python爬虫彩票案例,并自动发微信
import requests
from bs4 import BeautifulSoup
import itchat
import time,datetime all = [{1, 2, 3, 7, 8},
{1, 2, 3, 7, 9},
{1, 2, 3, 7, 10},
{1, 2, 3, 8, 9},
{1, 2, 3, 8, 10},
{1, 2, 3, 9, 10},
{1, 2, 4, 7, 8},
{1, 2, 4, 7, 9},
{1, 2, 4, 7, 10},
{1, 2, 4, 8, 9},
{1, 2, 4, 8, 10},
{1, 2, 4, 9, 10},
{1, 2, 5, 7, 8},
{1, 2, 5, 7, 9},
{1, 2, 5, 7, 10},
{1, 2, 5, 8, 9},
{1, 2, 5, 8, 10},
{1, 2, 5, 9, 10},
{1, 2, 6, 7, 8},
{1, 2, 6, 7, 9},
{1, 2, 6, 7, 10},
{1, 2, 6, 8, 9},
{1, 2, 6, 8, 10},
{1, 2, 6, 9, 10},
{1, 2, 7, 8, 9},
{1, 2, 7, 8, 10},
{1, 2, 7, 8, 11},
{1, 2, 7, 9, 10},
{1, 2, 7, 9, 11},
{1, 2, 7, 10, 11},
{1, 2, 8, 9, 10},
{1, 2, 8, 9, 11},
{1, 2, 8, 10, 11},
{1, 2, 9, 10, 11},
{1, 3, 4, 7, 8},
{1, 3, 4, 7, 9},
{1, 3, 4, 7, 10},
{1, 3, 4, 8, 9},
{1, 3, 4, 8, 10},
{1, 3, 4, 9, 10},
{1, 3, 5, 7, 8},
{1, 3, 5, 7, 9},
{1, 3, 5, 7, 10},
{1, 3, 5, 8, 9},
{1, 3, 5, 8, 10},
{1, 3, 5, 9, 10},
{1, 3, 6, 7, 8},
{1, 3, 6, 7, 9},
{1, 3, 6, 7, 10},
{1, 3, 6, 8, 9},
{1, 3, 6, 8, 10},
{1, 3, 6, 9, 10},
{1, 3, 7, 8, 9},
{1, 3, 7, 8, 10},
{1, 3, 7, 8, 11},
{1, 3, 7, 9, 10},
{1, 3, 7, 9, 11},
{1, 3, 7, 10, 11},
{1, 3, 8, 9, 10},
{1, 3, 8, 9, 11},
{1, 3, 8, 10, 11},
{1, 3, 9, 10, 11},
{1, 4, 5, 7, 8},
{1, 4, 5, 7, 9},
{1, 4, 5, 7, 10},
{1, 4, 5, 8, 9},
{1, 4, 5, 8, 10},
{1, 4, 5, 9, 10},
{1, 4, 6, 7, 8},
{1, 4, 6, 7, 9},
{1, 4, 6, 7, 10},
{1, 4, 6, 8, 9},
{1, 4, 6, 8, 10},
{1, 4, 6, 9, 10},
{1, 4, 7, 8, 9},
{1, 4, 7, 8, 10},
{1, 4, 7, 8, 11},
{1, 4, 7, 9, 10},
{1, 4, 7, 9, 11},
{1, 4, 7, 10, 11},
{1, 4, 8, 9, 10},
{1, 4, 8, 9, 11},
{1, 4, 8, 10, 11},
{1, 4, 9, 10, 11},
{1, 5, 6, 7, 8},
{1, 5, 6, 7, 9},
{1, 5, 6, 7, 10},
{1, 5, 6, 8, 9},
{1, 5, 6, 8, 10},
{1, 5, 6, 9, 10},
{1, 5, 7, 8, 9},
{1, 5, 7, 8, 10},
{1, 5, 7, 8, 11},
{1, 5, 7, 9, 10},
{1, 5, 7, 9, 11},
{1, 5, 7, 10, 11},
{1, 5, 8, 9, 10},
{1, 5, 8, 9, 11},
{1, 5, 8, 10, 11},
{1, 5, 9, 10, 11},
{2, 3, 4, 7, 8},
{2, 3, 4, 7, 9},
{2, 3, 4, 7, 10},
{2, 3, 4, 8, 9},
{2, 3, 4, 8, 10},
{2, 3, 4, 9, 10},
{2, 3, 5, 7, 8},
{2, 3, 5, 7, 9},
{2, 3, 5, 7, 10},
{2, 3, 5, 8, 9},
{2, 3, 5, 8, 10},
{2, 3, 5, 9, 10},
{2, 3, 6, 7, 8},
{2, 3, 6, 7, 9},
{2, 3, 6, 7, 10},
{2, 3, 6, 8, 9},
{2, 3, 6, 8, 10},
{2, 3, 6, 9, 10},
{2, 3, 7, 8, 9},
{2, 3, 7, 8, 10},
{2, 3, 7, 8, 11},
{2, 3, 7, 9, 10},
{2, 3, 7, 9, 11},
{2, 3, 7, 10, 11},
{2, 3, 8, 9, 10},
{2, 3, 8, 9, 11},
{2, 3, 8, 10, 11},
{2, 3, 9, 10, 11},
{2, 4, 5, 7, 8},
{2, 4, 5, 7, 9},
{2, 4, 5, 7, 10},
{2, 4, 5, 8, 9},
{2, 4, 5, 8, 10},
{2, 4, 5, 9, 10},
{2, 4, 6, 7, 8},
{2, 4, 6, 7, 9},
{2, 4, 6, 7, 10},
{2, 4, 6, 8, 9},
{2, 4, 6, 8, 10},
{2, 4, 6, 9, 10},
{2, 4, 7, 8, 9},
{2, 4, 7, 8, 10},
{2, 4, 7, 8, 11},
{2, 4, 7, 9, 10},
{2, 4, 7, 9, 11},
{2, 4, 7, 10, 11},
{2, 4, 8, 9, 10},
{2, 4, 8, 9, 11},
{2, 4, 8, 10, 11},
{2, 4, 9, 10, 11},
{2, 5, 6, 7, 8},
{2, 5, 6, 7, 9},
{2, 5, 6, 7, 10},
{2, 5, 6, 8, 9},
{2, 5, 6, 8, 10},
{2, 5, 6, 9, 10},
{2, 5, 7, 8, 9},
{2, 5, 7, 8, 10},
{2, 5, 7, 8, 11},
{2, 5, 7, 9, 10},
{2, 5, 7, 9, 11},
{2, 5, 7, 10, 11},
{2, 5, 8, 9, 10},
{2, 5, 8, 9, 11},
{2, 5, 8, 10, 11},
{2, 5, 9, 10, 11},
{3, 4, 5, 7, 8},
{3, 4, 5, 7, 9},
{3, 4, 5, 7, 10},
{3, 4, 5, 8, 9},
{3, 4, 5, 8, 10},
{3, 4, 5, 9, 10},
{3, 4, 6, 7, 8},
{3, 4, 6, 7, 9},
{3, 4, 6, 7, 10},
{3, 4, 6, 8, 9},
{3, 4, 6, 8, 10},
{3, 4, 6, 9, 10},
{3, 4, 7, 8, 9},
{3, 4, 7, 8, 10},
{3, 4, 7, 8, 11},
{3, 4, 7, 9, 10},
{3, 4, 7, 9, 11},
{3, 4, 7, 10, 11},
{3, 4, 8, 9, 10},
{3, 4, 8, 9, 11},
{3, 4, 8, 10, 11},
{3, 4, 9, 10, 11},
{3, 5, 6, 7, 8},
{3, 5, 6, 7, 9},
{3, 5, 6, 7, 10},
{3, 5, 6, 8, 9},
{3, 5, 6, 8, 10},
{3, 5, 6, 9, 10},
{3, 5, 7, 8, 9},
{3, 5, 7, 8, 10},
{3, 5, 7, 8, 11},
{3, 5, 7, 9, 10},
{3, 5, 7, 9, 11},
{3, 5, 7, 10, 11},
{3, 5, 8, 9, 10},
{3, 5, 8, 9, 11},
{3, 5, 8, 10, 11},
{3, 5, 9, 10, 11},
{4, 5, 6, 7, 8},
{4, 5, 6, 7, 9},
{4, 5, 6, 7, 10},
{4, 5, 6, 8, 9},
{4, 5, 6, 8, 10},
{4, 5, 6, 9, 10},
{4, 5, 7, 8, 9},
{4, 5, 7, 8, 10},
{4, 5, 7, 8, 11},
{4, 5, 7, 9, 10},
{4, 5, 7, 9, 11},
{4, 5, 7, 10, 11},
{4, 5, 8, 9, 10},
{4, 5, 8, 9, 11},
{4, 5, 8, 10, 11},
{4, 5, 9, 10, 11},]
ret_list=[
'http://chart.icaile.com/gd11x5.php',
'http://chart.icaile.com/',
'http://chart.icaile.com/jx11x5.php',
'http://chart.icaile.com/sh11x5.php',
'http://chart.icaile.com/js11x5.php',
'http://chart.icaile.com/yn11x5.php',
'http://chart.icaile.com/jl11x5.php',
'http://chart.icaile.com/nmg11x5.php',
'http://chart.icaile.com/ah11x5.php',
]
while True:
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
#和值大小
for i in ret_list: #循环9个省份
ret = requests.get(i) #爬数据
ret1 = ret.text #输出内容
soup = BeautifulSoup(ret1,'html.parser') #beautifulsoup解析
title = soup.title #获取title
periods = soup.find_all("td","chart-bg-qh") #找到所有期数
result = [] #去除所有和值
for period in periods:
period_text = int(period.get_text()) #每期期数
sum = int(period.find_next_siblings("td")[21].get_text()) #找到和值
last = sum % 10 #尾数
result.append(last) #将尾数加入空列表
result.reverse() #反转list,让最新的盘在前面
period_last = int(period.get_text())
result_big=[]
result_sml=[]
#判断大
for i in result:
if i > 4 :
result_big.append(i)
else:break
len_big = len(result_big) #查看大的有几期
print("%s %s ---大 -------%s期" % (title.get_text(), period_last,len_big))
if len_big > 8: #满足条件是发微信
print("\033[1;30;41m%s %s ---大 -------%s期\033[0m" % (title.get_text(), period_last, len_big))
try:
itchat.auto_login(hotReload=True) #微信登录
users = itchat.search_friends(name='Mo') #选择用户
userName = users[0]['UserName'] #用于发消息+
itchat.send(title.get_text()+ '----大'+ '-------'+str(len_big)+'期' + '----'+ datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') , toUserName=userName)
time.sleep(1)
except Exception as e:
print("微信发消息异常")
continue
#判断小
for i in result:
if i < 5 :
result_sml.append(i)
else:break
len_sml = len(result_sml) #查看小的有几期
print("%s %s ---小 -------%s期" % (title.get_text(), period_last, len_sml))
if len_sml > 8: #满足条件是发微信
print("\033[1;30;41m%s %s ---小 -------%s期\033[0m" % (title.get_text(), period_last, len_sml))
try:
itchat.auto_login(hotReload=True) #微信登录
users = itchat.search_friends(name='Mo') #选择用户
userName = users[0]['UserName'] #用于发消息+
itchat.send(title.get_text()+ '----小'+ '--------'+str(len_sml) +'期'+ '----'+ datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') , toUserName=userName)
time.sleep(1)
except Exception as e:
print("微信发消息异常")
continue
print('-------------------------------------------------------------')
#
for i in ret_list: #循环9个省份
ret = requests.get(i) #爬数据
ret1 = ret.text #输出内容
soup = BeautifulSoup(ret1,'html.parser') #beautifulsoup解析
title = soup.title #获取title
periods = soup.find_all("td","chart-bg-qh") #找到所有期数
period = periods[-1].get_text() #找到最后一期
four_all = soup.find_all("td","chart-bg-hmfb dqhm") #找到出奖号码中的4位
one_all = soup.find_all("td","chart-bg-kjhmo") #找到出奖号码中的1位
four_list = [] #所有的4位,加入一个列表
one_list = [] #所有的1位,加入一个列表
for i in four_all:
four = int(i.get_text())
four_list.append(four)
for i in one_all:
one = int(i.get_text())
one_list.append(one)
four_list_split = [four_list[i:i+4] for i in range(0,len(four_list),4)] #[[1, 3, 7, 9], [2, 6, 9, 11], [2, 4, 5, 8]]
one_list_split = [one_list[i:i + 1] for i in range(0, len(one_list),1)] #[[2], [4], [6], [8], [3]]
five_list = [] #生成开奖号码用
five_list_set = [] #转化为集合方式
five_23_ok = []
for i,j in zip(four_list_split,one_list_split): #开奖的五位数 [[1, 5, 6, 9, 7], [3, 4, 5, 9, 7], [2, 8, 9, 11, 4]]
five = i + j
five_list.append(five)
five_list.reverse() #将最新的排在前面
for i in five_list :
five_set = set(i)
five_list_set.append(five_set)
# print(five_list_set) #开奖的五位数 [{8, 9, 11, 4, 5}, {11, 8, 3, 5, 7}, {11, 9, 10, 3, 7}]
for i in five_list_set:
if i not in all:
five_23_ok.append(i)
else:break
len23 = len(five_23_ok)
print("%s %s ---23 -------%s期" % (title.get_text(),period ,len23))
if len23 > 6: #满足6期才发信息
try:
itchat.auto_login(hotReload=True) # 微信登录
users = itchat.search_friends(name='Mo') # 选择用户
userName = users[0]['UserName'] # 用于发消息+
itchat.send(title.get_text() + period +'----23'+'-------'+ str(len23)+'期' + '----' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
toUserName=userName)
time.sleep(1)
except Exception as e:
print("微信发消息异常")
continue
print('--------------------------------------------------------------')
itchat.logout()
time.sleep(60)
python爬虫彩票案例,并自动发微信的更多相关文章
- python 爬虫入门----案例爬取上海租房图片
前言 对于一个net开发这爬虫真真的以前没有写过.这段时间学习python爬虫,今天周末无聊写了一段代码爬取上海租房图片,其实很简短就是利用爬虫的第三方库Requests与BeautifulSoup. ...
- 如何用Python爬虫实现百度图片自动下载?
Github:https://github.com/nnngu/LearningNotes 制作爬虫的步骤 制作一个爬虫一般分以下几个步骤: 分析需求 分析网页源代码,配合开发者工具 编写正则表达式或 ...
- 23个Python爬虫开源项目代码,包含微信、淘宝、豆瓣、知乎、微博等
今天为大家整理了23个Python爬虫项目.整理的原因是,爬虫入门简单快速,也非常适合新入门的小伙伴培养信心,所有链接指向GitHub,微信不能直接打开,老规矩,可以用电脑打开. 关注公众号「Pyth ...
- python 爬虫入门案例----爬取某站上海租房图片
前言 对于一个net开发这爬虫真真的以前没有写过.这段时间开始学习python爬虫,今天周末无聊写了一段代码爬取上海租房图片,其实很简短就是利用爬虫的第三方库Requests与BeautifulSou ...
- Python爬虫入门案例:获取百词斩已学单词列表
百词斩是一款很不错的单词记忆APP,在学习过程中,它会记录你所学的每个单词及你答错的次数,通过此列表可以很方便地找到自己在记忆哪些单词时总是反复出错记不住.我们来用Python来爬取这些信息,同时学习 ...
- python爬虫实战(三)--------搜狗微信文章(IP代理池和用户代理池设定----scrapy)
在学习scrapy爬虫框架中,肯定会涉及到IP代理池和User-Agent池的设定,规避网站的反爬. 这两天在看一个关于搜狗微信文章爬取的视频,里面有讲到ip代理池和用户代理池,在此结合自身的所了解的 ...
- 4.Python爬虫小案例
1.网络爬虫定义:按照一定的规则,自动的抓取网站信息的程序或者脚本. 2.流程:request打开url得到html文档==浏览器打开源码分析元素节点==通过BeautifulSoup得到想要的数据= ...
- Python爬虫实战案例:取喜马拉雅音频数据详解
前言 喜马拉雅是专业的音频分享平台,汇集了有声小说,有声读物,有声书,FM电台,儿童睡前故事,相声小品,鬼故事等数亿条音频,我最喜欢听民间故事和德云社相声集,你呢? 今天带大家爬取喜马拉雅音频数据,一 ...
- Python爬虫实战案例:爬取爱奇艺VIP视频
一.实战背景 爱奇艺的VIP视频只有会员能看,普通用户只能看前6分钟.比如加勒比海盗5的URL:http://www.iqiyi.com/v_19rr7qhfg0.html#vfrm=19-9-0-1 ...
随机推荐
- [GUI] Linux中的图形管理
转:http://www.cnblogs.com/yongpenghan/p/4555619.html 做了一段时间linux下与QT事件相关的工作,经常会遇到X11,总是苦于无法完全理解其与linu ...
- accept= 'image/*'反映缓慢
input[type='file']的accept属性用来指定上传文件的MIME类型. 将其设为accept= 'image/*',顾名思义,过滤掉所有非图片文件, 但在实际操作中,发现有时会出现响应 ...
- 20145240 《Java程序设计》第五周学习总结
20145240 <Java程序设计>第五周学习总结 教材学习内容总结 语法与继承结构 8.1.1使用try.catch java中所有的错误都会被打包为对象,并提供了特有的语句进行处理. ...
- cocos2dx打飞机项目笔记六:GameScene类和碰撞检测 boundingbox
GameScene类虽然是占用游戏最多时间的类,但是里面的东西不是很多,最重要的就是碰撞检测了,碰撞检测代码如下: void GameScene::detectionCrash() { CCArray ...
- VMware VIC
vSphere Integrated Containers - a short intro High-Level view of VCH Networking vSphere Integrated C ...
- uvalive 6938 区间dp
看到n范围和给的区间看着就像区间dp 然后怎么cmp感觉都没法进行区间合并 n的300误导了下 没有注意离散化之后对时间可以dp 然而这个dp感觉不太经得起证明的样子... dp[i][j] -> ...
- @RequestMapping
可以设定访问的目录,与访问的方式 对象可以是类,也可以是方法 @RequestMapping(value = "/say",method = RequestMethod.GET) ...
- OpenStack for NFV applications: enabling Single Root I/O virtualization and PCI-Passthrough
http://superuser.openstack.org/articles/openstack-for-nfv-applications-enabling-single-root-i-o-virt ...
- js中出现问题--Type Syntax error on token "catch", Identifier expected jquery.js
解决方案: 1.选中jQuery报错的web工程: 2.右键-->Myeclipse-->Exclude From Validation,选中: 3.继续右键Myeclipse--> ...
- VMware Workstation Pro v14.0
早些时候戴尔旗下的虚拟化软件 VMware Pro v14 版正式发布,本次更新主要是优化对创意者更新版的支持. 创意者更新版是目前微软 Windows 10 系统的最新版本,该版本亦会在十月份成为C ...