Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to send QQ group messages automatically in Python

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to send QQ group messages automatically in Python. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Preparatory work

This test is based on python3 and requires the installation of qqbot, bs4 and requests libraries.

Pip qqbot pip install bs4pip install requests# changes qqbot profile

The following configuration is to complete the authorization operation by sending the authorization QR code by email.

two。 Code part # coding:UTF-8import qqbotimport requestsimport bs4import time##SentQQclass QQ (object): def _ _ init__ (self): self.qqnumber = '1234567890' self.message =' information automatic push function testfully pushed' Self.groupname = ['communication group'] self.bot = qqbot._bot def sendMsgToGroup (self,msg,group,bot): for group in group: bg=bot.List ('group', group) if bg is not None: bot.SendTo (bg [0], msg) def main (self): self.bot.Login (['-q') Self.qqnumber]) self.sendMsgToGroup (self.message,self.groupname,self.bot) # # crawl data class GetData (object): def _ init__ (self): self.rooturl = 'https://www.xxxx.com' self.url = self.rooturl +' / ah/20?lang=1' self.headers = {'User-Agent':' Mozilla/5.0 (Macintosh) Intel Mac OS X 10: 13: 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'} def getdata (self): response = requests.get (self.url,headers=self.headers) if int (response.status_code) = 200: htmldata = bs4.BeautifulSoup (response.text 'html.parser') blognumber = 0 result = "[% s] Technical article recommendation:\ n\ n"% (time.strftime ('% Ymuri% MMI% dhammer.localtime (time.time () for k in htmldata.find_all ('a'): if blognumber

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report