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

首頁 > 編程 > Python > 正文

itchat接口使用示例

2020-02-16 10:27:33
字體:
供稿:網(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ù)分析那個公眾號的一篇文章敲得,是可以運(yùn)行了。具體的代碼不到五十行:

#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)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站:python實(shí)現(xiàn)微信接口(itchat)詳細(xì)介紹、基于Python和Scikit-Learn的機(jī)器學(xué)習(xí)探索等,有什么問題可以隨時留言,小編會及時回復(fù)大家的。感謝朋友們對本站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 洪湖市| 开封县| 阳原县| 云南省| 普定县| 元阳县| 南雄市| 绥阳县| 康平县| 临潭县| 林甸县| 乌海市| 楚雄市| 湟源县| 柞水县| 富川| 扎赉特旗| 洞口县| 和龙市| 聊城市| 临沂市| 廉江市| 海口市| 广东省| 隆回县| 武清区| 南乐县| 昌图县| 丰原市| 璧山县| 甘孜| 洛阳市| 十堰市| 鹤壁市| 开阳县| 平远县| 贡觉县| 兖州市| 兴和县| 天等县| 抚宁县|