python使用chatgpt自动帮你抖音直播公屏消息回复互动聊天代码

代码语言:python

所属分类:人工智能

代码描述:python使用chatgpt自动帮你抖音直播公屏消息回复互动聊天代码

代码标签: python chatgpt 抖音 直播 消息 公屏 互动 回复 消息 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
import openai

openai.api_key = "openaikey"

def getopenairesponse(keyword):
    msg = [{"role": "user", "content": 'Hello World'}]
    msg[0]['content'] = keyword
    completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=msg)
    return completion.choices

# 创建浏览器实例
#driver = webdriver.Chrome()

options = webdriver.ChromeOptions() 
#options.add_argument('headless')

driver = webdriver.Chrome(chrome_options=options)
driver.get('https://live.douyin.com/929789927078')
cookie_string="tt_scid=131233242sdfsdfsg(*798wr3sfs; passport_fe_beating_status=false"
cookies = [cookie.strip() for cookie in cookie_string.split(';')] 
cookies = [cookie.split('=') for cookie in cookies if cookie]  
cookies = [{'name': cookie[0], 'value': cookie[1],"domain":"live.douyin.com"} for cookie in cookies]
print(cookies)
for c in cookies:
    driver.add_cookie(c)

# cookie = {
#     'name': 'cookie_name',
#     'value': 'cookie_value'
# }
driver.refresh()

# driver.add_cookie(cookie)

# 进入指.........完整代码请登录后点击上方下载按钮下载查看

网友评论0