国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

itchat接口使用示例

2020-01-04 16:38:31
字體:
供稿:網(wǎng)友

有關(guān)itchat接口的知識,小編是初步學(xué)習(xí),這里先給大家分享一段代碼用法示例。

sudo pip3 install itchat

今天用了下itchat接口,從url=”https://lvyou.baidu.com/”上爬了數(shù)據(jù),可以根據(jù)對方發(fā)的城市拼音比如qingdao自動回復(fù)這個城市的旅游信息。

有很多地方還沒搞明白,但是程序照著數(shù)據(jù)分析那個公眾號的一篇文章敲得,是可以運行了。具體的代碼不到五十行:

#Coding='utf-8'from time import ctimefrom bs4 import BeautifulSoupimport itchatimport urllib.requestfrom pandas import Seriesitchat.login()Help="""please input pinyinsuch 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()

總結(jié)

以上就是本文關(guān)于itchat接口使用示例的全部內(nèi)容,希望對大家有所幫助。有什么問題可以隨時留言,小編會及時回復(fù)大家的。感謝朋友們對本站的支持!


注:相關(guān)教程知識閱讀請移步到python教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 鹤峰县| 彩票| 当雄县| 甘南县| 石嘴山市| 东乌| 娱乐| 东至县| 华阴市| 凭祥市| 三门县| 高尔夫| 赤城县| 卢湾区| 平阴县| 三亚市| 田林县| 祁东县| 驻马店市| 浮梁县| 朔州市| 怀来县| 禹州市| 乌拉特前旗| 陕西省| 盘锦市| 梅州市| 清河县| 阳原县| 方城县| 湘潭市| 桃源县| 临湘市| 通化县| 收藏| 茌平县| 津南区| 诸暨市| 海口市| 全州县| 阆中市|