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爬虫彩票案例,并自动发微信的更多相关文章

  1. python 爬虫入门----案例爬取上海租房图片

    前言 对于一个net开发这爬虫真真的以前没有写过.这段时间学习python爬虫,今天周末无聊写了一段代码爬取上海租房图片,其实很简短就是利用爬虫的第三方库Requests与BeautifulSoup. ...

  2. 如何用Python爬虫实现百度图片自动下载?

    Github:https://github.com/nnngu/LearningNotes 制作爬虫的步骤 制作一个爬虫一般分以下几个步骤: 分析需求 分析网页源代码,配合开发者工具 编写正则表达式或 ...

  3. 23个Python爬虫开源项目代码,包含微信、淘宝、豆瓣、知乎、微博等

    今天为大家整理了23个Python爬虫项目.整理的原因是,爬虫入门简单快速,也非常适合新入门的小伙伴培养信心,所有链接指向GitHub,微信不能直接打开,老规矩,可以用电脑打开. 关注公众号「Pyth ...

  4. python 爬虫入门案例----爬取某站上海租房图片

    前言 对于一个net开发这爬虫真真的以前没有写过.这段时间开始学习python爬虫,今天周末无聊写了一段代码爬取上海租房图片,其实很简短就是利用爬虫的第三方库Requests与BeautifulSou ...

  5. Python爬虫入门案例:获取百词斩已学单词列表

    百词斩是一款很不错的单词记忆APP,在学习过程中,它会记录你所学的每个单词及你答错的次数,通过此列表可以很方便地找到自己在记忆哪些单词时总是反复出错记不住.我们来用Python来爬取这些信息,同时学习 ...

  6. python爬虫实战(三)--------搜狗微信文章(IP代理池和用户代理池设定----scrapy)

    在学习scrapy爬虫框架中,肯定会涉及到IP代理池和User-Agent池的设定,规避网站的反爬. 这两天在看一个关于搜狗微信文章爬取的视频,里面有讲到ip代理池和用户代理池,在此结合自身的所了解的 ...

  7. 4.Python爬虫小案例

    1.网络爬虫定义:按照一定的规则,自动的抓取网站信息的程序或者脚本. 2.流程:request打开url得到html文档==浏览器打开源码分析元素节点==通过BeautifulSoup得到想要的数据= ...

  8. Python爬虫实战案例:取喜马拉雅音频数据详解

    前言 喜马拉雅是专业的音频分享平台,汇集了有声小说,有声读物,有声书,FM电台,儿童睡前故事,相声小品,鬼故事等数亿条音频,我最喜欢听民间故事和德云社相声集,你呢? 今天带大家爬取喜马拉雅音频数据,一 ...

  9. Python爬虫实战案例:爬取爱奇艺VIP视频

    一.实战背景 爱奇艺的VIP视频只有会员能看,普通用户只能看前6分钟.比如加勒比海盗5的URL:http://www.iqiyi.com/v_19rr7qhfg0.html#vfrm=19-9-0-1 ...

随机推荐

  1. Android 上Camera分析

    http://blog.csdn.net/u010503912/article/details/52315721 Android Camera 系统架构源码分析(1)---->Camera的初始 ...

  2. P4317 花神的数论题

    题目 洛谷 数学方法学不会%>_<% 做法 爆搜二进制下存在\(i\)位\(1\)的情况,然后快速幂乘起来 My complete code #include<bits/stdc++ ...

  3. id和NSObject *和instanceType的区别与联系

    id 被成为万能指针,也就是可以指向任何对象. NSObject * 本身就是定义指向NSObject类型的指针. 那么这两者有什么区别吗? 这两者都是既可以作为返回值,又可以作为变量修饰.而其主要区 ...

  4. OC_id类型

     博客正式开通啦!以后会每天为大家更新知识,将过去学习的笔记发布出来.供大家学习交流. 在Objective-C 中,id 类型是一个独特的数据类型.在概念上,类似Java 的Object 类,可以转 ...

  5. constexpr与指针

    一. 常量表达式:是指值不会改变并且在编译过程就能得到的计算结果的表达式. 定义常量表达式变量: constexpr 变量类型 变量名: 例如: constexpr int mf=20://///20 ...

  6. MySQLdump导出sql脚本

    1.问题描述 通过图形化工具,在查询窗口用select语句按条件查询出所需结果,然后用“导出向导”把查询结果导成sql文件,但是导出来的sql语句不全,没有表名.字段名. 通过图形化工具,试了好多次都 ...

  7. Oracle数据库连接生成DDL

    package com.bbkj; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Prepare ...

  8. EntityFramework 学习 一 Validate Entity

    可以为实体实现自定义验证,重写DBContext中的个ValidateEntity方法 protected override System.Data.Entity.Validation.DbEntit ...

  9. jquery的队列问题

    队列,可以当成一个数组,也可以当成一个空间. 使用的地方: 在js这种异步操作的时候,我们不知道什么时候一个js代码加载完成,并且你还要保护一段代码只有一个模块在执行(按需加载的时候) 这个时候我们就 ...

  10. DecimalFormat数据格式函数

    DecimalFormat数据格式函数 class FormatDemo2{ public void format(String pattern, double value) { DecimalFor ...