1、生成二维码:
import qrcode
import image
img = qrcode.make('http://www.baidu.com')
img.save('hello.png') 生成二维码,扫完之后自动跳转到百度
2、itchat模块
import random
import time
import itchat
#登录缓存
hotReload = True
itchat.auto_login()
#发送消息或者文件给微信手机助手
while True:
itchat.send('hello westos',toUserName='filehelper')
itchat.send_file('/tmp/passwd',toUserName='filehelper')
time.sleep(random.randint(1,3))
#获取微信好友并且进行数据处理
friends = itchat.get_friends()
info = {}
for friend in friends[1:]:
if friend['Sex'] == 1:
info['male'] = info.get('male',0) + 1
elif friend['Sex'] == 2:
info['female'] = info.get('female', 0) + 1
else:
info['other'] = info.get('other',0) + 1
3、手机远程执行控制电脑
import os
import itchat
@itchat.msg_register(itchat.content.TEXT,isFriendChat=True)
def text_reply(msg):
if msg['ToUserName'] == 'filehelper':
#获取要执行的命令内容
command = msg['Content']
#系统执行代码
if os.system(command) == 0:
res = os.popen(command).read()
result = '[返回值]-命令%s执行成功,执行结果: \n' + res
itchat.send(result,'filehelper')
else:
result = '[返回值]-命令%s执行失败,请检查命令: \n' %(command)
itchat.send(result,'filehelper')
itchat.auto_login()
itchat.run()
4、图灵机器人
import itchat
import requests
def get_tuling_respose(_info):
print(_info)
api_url = 'http://www.tuling123.com/openapi/api'
data = {
'key':'f90956d3a9f947be95ec28e02a52ce58',
'info':_info,
'userid':'lily'
}
res = requests.post(api_url,data).json()
# print(res,type(res))
print(res['text'])
return (res['text'])
#get_tuling_respose('给我讲个笑话')
#get_tuling_respose('不好笑')
@itchat.msg_register(itchat.content.TEXT,isFriendChat=True)
def text_reply(msg):
content = msg['Content']
returnContent = get_tuling_respose(content)
return returnContent
itchat.auto_login()
itchat.run()