Use python making a funny robot micro letter

(Students may want to see more details refer to: https: //www.cnblogs.com/liyanyinng/p/10963105.html)

Using the robot in the python produce small micro-channel, the following code can look at the following

. 1  # - * - Coding: UTF-. 8 - * - 
2  Import itchat
 . 3  Import Requests
 . 4  
. 5  DEF get_response was (MSG):
 . 6      apiurl = ' http://i.itpk.cn/api.php '   # // robot Moli URL 
. 7      Data = {
 . 8          " Question " : MSG,     # // chat text information acquired 
. 9          " api_key " : " 494cb6649ff24eefa464fb546bf50d56 " ,
 10          # "api_secret": "n4gxkdyckd7p" 
. 11      }
12 is  
13 is      R & lt requests.post = (apiurl, Data = Data)   # // network configuration request 
14      return r.text
 15 @ itchat.msg_register (itchat.content.TEXT)      # // buddy processing messages 
16  DEF print_content (MSG) :
 . 17      return get_response was (MSG [ ' the Text ' ])
 18 is @ itchat.msg_register ([itchat.content.TEXT], isGroupChat = True)     # // group message processing 
. 19  DEF print_content (MSG):
 20 is      return get_response was (MSG [ ' the Text ' ])
 21 is itchat.auto_login (True)           # // automatically log 
22 itchat.run ()                        # // start the bot

Copy the code above what we can go to look at the micro-letter friends (there will be surprises)

Look at it is like this.

 

Guess you like

Origin www.cnblogs.com/liyanyinng/p/10968432.html