欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Python3实现的腾讯微博自动发帖小工具

程序员文章站 2022-05-06 20:22:42
...
代码如下:


# -*- coding: UTF-8 -*-
import mysql.connector as db
import client.tWeibo
import time

if __name__ == '__main__':
connect = db.connect(user='root',db='collection',password='',host="127.0.0.1")
cursor = connect.cursor()
cursor.execute("SET SQL_MODE = 'TRADITIONAL'")
uin = 'QQ号'
passwd = '密码'
wb = client.tWeibo.tWeibo(uin, passwd)
wb.login()
sqlSelectTwitter = "SELECT `content`,`pic` FROM `collection`.`weibo_content2` ORDER BY `id` DESC LIMIT 0, 144"
cursor.execute(sqlSelectTwitter)
for (content, pic) in cursor:
result = wb.publish(content, pic)
print(result)
print("暂停10分钟......")
time.sleep(600)
cursor.close()
connect.close()