最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

itchat接口使用示例

 更新時(shí)間:2017年10月23日 10:20:39   作者:螢火之森_1  
這篇文章主要介紹了itchat接口使用示例,itchat接口的相關(guān)知識,這里是一段代碼示例,這里分享給大家,供需要的朋友參考。努力學(xué)習(xí)中~

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

sudo pip3 install itchat

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

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

#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()

總結(jié)

以上就是本文關(guān)于itchat接口使用示例的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站:python實(shí)現(xiàn)微信接口(itchat)詳細(xì)介紹、基于Python和Scikit-Learn的機(jī)器學(xué)習(xí)探索等,有什么問題可以隨時(shí)留言,小編會及時(shí)回復(fù)大家的。感謝朋友們對本站的支持!

相關(guān)文章

最新評論

新竹县| 靖州| 三原县| 礼泉县| 固镇县| 个旧市| 法库县| 沈阳市| 东丰县| 乌拉特后旗| 邢台县| 磴口县| 盐池县| 墨脱县| 茶陵县| 上虞市| 乌拉特中旗| 阳西县| 华安县| 吉木萨尔县| 米脂县| 灌阳县| 繁峙县| 泸州市| 霍山县| 屏边| 江陵县| 出国| 安塞县| 佛山市| 通道| 高唐县| 莫力| 海口市| 扎赉特旗| 达日县| 苗栗市| 扎囊县| 伊春市| 西平县| 定兴县|