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

python實(shí)現(xiàn)向微信用戶發(fā)送每日一句 python實(shí)現(xiàn)微信聊天機(jī)器人

 更新時間:2019年03月27日 14:55:50   作者:回憶是如此憂傷  
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)向微信用戶發(fā)送每日一句,python調(diào)實(shí)現(xiàn)微信聊天機(jī)器人,具有一定的參考價值,感興趣的小伙伴們可以參考一下

分享幾個Python針對微信的小工具,供大家參考,具體內(nèi)容如下

用Python實(shí)現(xiàn)向微信用戶發(fā)送每日一句

# -*- coding:utf-8 -*-
from __future__ import unicode_literals
from threading import Timer
from wxpy import *
import requests
#bot = Bot()
#bot = Bot(console_qr=2,cache_path="botoo.pkl")#這里的二維碼是用像素的形式打印出來!,如果你在win環(huán)境上運(yùn)行,替換為 bot=Bot()
bot = Bot(cache_path=True)
 
def get_news1():
#獲取金山詞霸每日一句,英文和翻譯
 url = "http://open.iciba.com/dsapi/"
 r = requests.get(url)
 contents = r.json()['content']
 translation= r.json()['translation']
 return contents,translation
def send_news():
 try:
  my_friend = bot.friends().search(u'浩')[0] #你朋友的微信名稱,不是備注,也不是微信帳號。
  my_friend.send(get_news1()[0])
  my_friend.send(get_news1()[1][5:])
  my_friend.send(u"以上是金山詞霸每日一句,http://www.qq.com\" data-miniprogram-appid=\"wxae430cc3e778834b\" data-miniprogram-path=\"pages/goLogin/goLogin\"")
  t = Timer(10, send_news)#每86400秒(1天),發(fā)送1次,不用linux的定時任務(wù)是因?yàn)槊看蔚顷懚夹枰獟呙瓒S碼登陸,很麻煩的一件事,就讓他一直掛著吧
  t.start()
 except:
  my_friend = bot.friends().search('回憶總是如此傷')[0]#你的微信名稱,不是微信帳號。
  my_friend.send(u"今天消息發(fā)送失敗了")
if __name__ == "__main__":
 send_news()

用Python調(diào)用圖靈機(jī)器人接口實(shí)現(xiàn)微信聊天機(jī)器人

import kivy
 
kivy.require('1.9.1')
from kivy.app import App
from kivy.uix.button import Button
import itchat
import requests
 
class test(App):
 def get_response(msg):
  apiUrl = 'http://www.tuling123.com/openapi/api'
  data = {
   'key': '0646d90819004f2fa565852c0fe3c3af', # Tuling Key
   'info': msg, # 這是我們發(fā)出去的消息
   'userid': '123', # 這里你想改什么都可以
  }
  # 我們通過如下命令發(fā)送一個post請求
  r = requests.post(apiUrl, data=data).json()
  return r.get('text')
 
 @itchat.msg_register(itchat.content.TEXT)
 def print_content(msg):
  return get_response(msg['Text'])
 
 @itchat.msg_register([itchat.content.TEXT], isGroupChat=True)
 def print_content(msg):
  return get_response(msg['Text'])
 
 itchat.auto_login(True)
 itchat.run()
 
 
if __name__ == '__main__':
 test().run()

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

城固县| 华容县| 江北区| 鄄城县| 龙胜| 龙海市| 康马县| 洮南市| 佛山市| 于都县| 连平县| 白河县| 彭阳县| 正定县| 康平县| 龙江县| 北安市| 鸡西市| 周至县| 天柱县| 兴安县| 全州县| 石家庄市| 丰县| 望江县| 南雄市| 临颍县| 金山区| 阳城县| 富川| 余江县| 吉林市| 时尚| 上虞市| 澳门| 贵溪市| 外汇| 铁力市| 三江| 柳林县| 阆中市|