feat: 增加Docker容器环境
This commit is contained in:
@@ -5,14 +5,14 @@ from playwright.async_api import Playwright, async_playwright, Page
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
from conf import LOCAL_CHROME_PATH
|
||||
from conf import LOCAL_CHROME_PATH, LOCAL_CHROME_HEADLESS
|
||||
from utils.base_social_media import set_init_script
|
||||
from utils.log import douyin_logger
|
||||
|
||||
|
||||
async def cookie_auth(account_file):
|
||||
async with async_playwright() as playwright:
|
||||
browser = await playwright.chromium.launch(headless=True)
|
||||
browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
|
||||
context = await browser.new_context(storage_state=account_file)
|
||||
context = await set_init_script(context)
|
||||
# 创建一个新的页面
|
||||
@@ -48,7 +48,7 @@ async def douyin_setup(account_file, handle=False):
|
||||
async def douyin_cookie_gen(account_file):
|
||||
async with async_playwright() as playwright:
|
||||
options = {
|
||||
'headless': False
|
||||
'headless': LOCAL_CHROME_HEADLESS
|
||||
}
|
||||
# Make sure to run headed.
|
||||
browser = await playwright.chromium.launch(**options)
|
||||
@@ -72,6 +72,7 @@ class DouYinVideo(object):
|
||||
self.account_file = account_file
|
||||
self.date_format = '%Y年%m月%d日 %H:%M'
|
||||
self.local_executable_path = LOCAL_CHROME_PATH
|
||||
self.headless = LOCAL_CHROME_HEADLESS
|
||||
self.thumbnail_path = thumbnail_path
|
||||
self.productLink = productLink
|
||||
self.productTitle = productTitle
|
||||
@@ -99,9 +100,9 @@ class DouYinVideo(object):
|
||||
async def upload(self, playwright: Playwright) -> None:
|
||||
# 使用 Chromium 浏览器启动一个浏览器实例
|
||||
if self.local_executable_path:
|
||||
browser = await playwright.chromium.launch(headless=False, executable_path=self.local_executable_path)
|
||||
browser = await playwright.chromium.launch(headless=self.headless, executable_path=self.local_executable_path)
|
||||
else:
|
||||
browser = await playwright.chromium.launch(headless=False)
|
||||
browser = await playwright.chromium.launch(headless=self.headless)
|
||||
# 创建一个浏览器上下文,使用指定的 cookie 文件
|
||||
context = await browser.new_context(storage_state=f"{self.account_file}")
|
||||
context = await set_init_script(context)
|
||||
|
||||
Reference in New Issue
Block a user