欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

用Python實現(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)境上運行,替換為 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ù)是因為每次登陸都需要掃描二維碼登陸,很麻煩的一件事,就讓他一直掛著吧
  t.start()
 except:
  my_friend = bot.friends().search('回憶總是如此傷')[0]#你的微信名稱,不是微信帳號。
  my_friend.send(u"今天消息發(fā)送失敗了")
if __name__ == "__main__":
 send_news()

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

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é)習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • python實現(xiàn)最速下降法

    python實現(xiàn)最速下降法

    這篇文章主要為大家詳細介紹了python實現(xiàn)最速下降法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-03-03
  • Python實現(xiàn)自動識別并填加驗證碼的示例代碼

    Python實現(xiàn)自動識別并填加驗證碼的示例代碼

    實現(xiàn)自動識別網(wǎng)頁中的驗證碼并填寫,需要結(jié)合使用網(wǎng)絡(luò)爬蟲技術(shù)、圖像識別(OCR),以及可能的瀏覽器自動化工具(如Selenium),本文給大家介紹了Python實現(xiàn)自動識別并填加驗證碼的示例,需要的朋友可以參考下
    2024-06-06
  • python+selenium 鼠標事件操作方法

    python+selenium 鼠標事件操作方法

    今天小編就為大家分享一篇python+selenium 鼠標事件操作方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08
  • 最新評論