幽灵资源网 Design By www.bzswh.com
有关itchat接口的知识,小编是初步学习,这里先给大家分享一段代码用法示例。
sudo pip3 install itchat
今天用了下itchat接口,从url=”https://lvyou.baidu.com/”上爬了数据,可以根据对方发的城市拼音比如qingdao自动回复这个城市的旅游信息。
有很多地方还没搞明白,但是程序照着数据分析那个公众号的一篇文章敲得,是可以运行了。具体的代码不到五十行:
#Coding='utf-8' from time import ctime from bs4 import BeautifulSoup import itchat import urllib.request from pandas import Series itchat.login() Help="""please input pinyin such as 巨野--juye """ itchat.send(Help,toUserName='filehelper') @itchat.msg_register(itchat.content.TEXT) def getcity(msg): print(msg['Text']) pinyin=msg["Text"] results=getTOUR(pinyin) itchat.send(results,msg["FromUserName"]) def getTOUR(pinyin): try: url="https://lvyou.baidu.com/"+pinyin#ba xiamen tihuancheng pinyin page=urllib.request.urlopen(url) html=page.read() soup=BeautifulSoup(html.decode('utf-8'),"html.parser") name=soup.find("h3",{'class',"title"}).text grade = soup.find("div", {'class', "main-score"}).text describe = soup.find("p", {'class', "main-desc-p"}).text season = soup.find("span", {'class', "main-besttime"}).text advice = soup.find("span", {'class', "main-dcnt"}).text output=name+'\n'+grade+'\n'+describe+'\n'+season+'\n'+advice+'*'*25+u'\n推荐:' except NameError: output="not found this place,please ensure that your input place is exist" return output #sites=soup.find_all('div',{'class','unmis-li'}) if __name__== '__main__': itchat.run()
总结
以上就是本文关于itchat接口使用示例的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:python实现微信接口(itchat)详细介绍、基于Python和Scikit-Learn的机器学习探索等,有什么问题可以随时留言,小编会及时回复大家的。感谢朋友们对本站的支持!
幽灵资源网 Design By www.bzswh.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
幽灵资源网 Design By www.bzswh.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。