rpa m
This commit is contained in:
parent
e3b89249f6
commit
4001249d53
|
|
@ -6,10 +6,12 @@ import time
|
|||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
import httpx
|
||||
from ulid import ULID
|
||||
|
||||
import modal
|
||||
from loguru import logger
|
||||
from playwright.async_api import async_playwright, Browser, Page
|
||||
from playwright.sync_api import sync_playwright
|
||||
from tenacity import retry, stop_after_attempt, wait_fixed
|
||||
from functools import partial
|
||||
|
||||
|
|
@ -24,7 +26,7 @@ rpa_image = (modal.Image.debian_slim(python_version="3.11")
|
|||
"mkdir /root/browsers",
|
||||
"playwright install-deps",
|
||||
"playwright install chromium",
|
||||
"playwright install msedge",
|
||||
"playwright install --force msedge",
|
||||
])
|
||||
.add_local_python_source('cluster')
|
||||
.add_local_python_source('BowongModalFunctions')
|
||||
|
|
@ -528,6 +530,8 @@ with rpa_image.imports():
|
|||
await page.wait_for_load_state("networkidle", timeout=5 * 1000)
|
||||
logger.info(f"networkidle to end {url}")
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@app.local_entrypoint()
|
||||
async def local_run():
|
||||
|
|
@ -537,7 +541,7 @@ with rpa_image.imports():
|
|||
# webcast_ids = ["36861064178"]
|
||||
webcast_id = "333555252930"
|
||||
|
||||
data: LiveStreamProductWatchRequest = LiveStreamProductWatchRequest(live_id=webcast_id)
|
||||
data: LiveStreamProductWatchRequest = LiveStreamProductWatchRequest(live_id=webcast_id,live_stream_name=str(ULID()))
|
||||
# TODO other info
|
||||
call_id = submit_job(data)
|
||||
print("------call_id:", call_id)
|
||||
|
|
@ -560,7 +564,11 @@ with rpa_image.imports():
|
|||
# logger.info(f"title = {title}")
|
||||
|
||||
########################################rpa_image end######################################################
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
|
||||
def local_main_test():
|
||||
global client, status_code
|
||||
with httpx.Client(timeout=120) as client:
|
||||
res = client.post(url="https://bowong-gateway.bowong.cc/api/t1/live/createLivePull2Push", json={
|
||||
"name": "62997236617212111",
|
||||
|
|
@ -570,3 +578,21 @@ if __name__ == '__main__':
|
|||
status_code = res.raise_for_status().status_code
|
||||
print(status_code)
|
||||
print(res.json())
|
||||
|
||||
def foo(webcast_id):
|
||||
with sync_playwright() as p:
|
||||
url = f"https://live.douyin.com/{webcast_id}?open_promotion_list=1"
|
||||
# Channel can be "chrome", "msedge", "chrome-beta", "msedge-beta" or "msedge-dev".
|
||||
browser = p.chromium.launch(channel="msedge")
|
||||
page = browser.new_page()
|
||||
page.goto(url)
|
||||
print(page.title())
|
||||
browser.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# local_main_test()
|
||||
foo("333555252930")
|
||||
|
||||
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in New Issue