2 files modified
1 files added
| | |
| | | asyncio~=3.4.3 |
| | | keyring~=24.3.1 |
| | | setuptools~=70.0.0 |
| | | playwright~=1.44.0 |
| | | playwright~=1.42.0 |
| | | loguru~=0.7.2 |
| | | wheel~=0.41.3 |
| | |
| | | import asyncio |
| | | import random |
| | | import re |
| | | import time |
| | | from typing import Optional |
| | | from loguru import logger |
| | | from playwright.async_api import async_playwright, BrowserContext |
| | |
| | | |
| | | async def transform(short_urls: list): |
| | | async with async_playwright() as playwright: |
| | | browser = await playwright.chromium.launch(headless=False, args=[f'--remote-debugging-port={random.randint(9000, 9300)}']) |
| | | browser = await playwright.chromium.launch(headless=True, args=[f'--remote-debugging-port={random.randint(9000, 9300)}']) |
| | | context = await browser.new_context() |
| | | |
| | | task_queue = asyncio.Queue() |
| | |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | url_list = grad_post_dao.get_post_info() |
| | | logger.info(f'查询到待处理数据: {len(url_list)}条') |
| | | # [{'id': 17, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osyERT/ qEH:/ 07/26 N@j.cN '}, {'id': 18, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osDbEa/ wFh:/ C@h.Bg 02/07 '}, {'id': 19, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osB5xs/ WMW:/ s@e.Bg 03/15 '}, {'id': 20, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osdAHC/ 07/01 w@S.yT DUY:/ '}, {'id': 21, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osU8Ag/ 02/04 icN:/ c@N.jC '}, {'id': 22, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osNTND/ 01/18 iCH:/ t@E.Hv '}, {'id': 23, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osVTXq/ l@P.Xm 11/21 JII:/ '}, {'id': 24, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6ossrjm/ V@Y.Mj dnD:/ 12/24 '}, {'id': 25, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6osufkc/ 01/24 S@l.PX eOx:/ '}, {'id': 26, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6os4Yw3/ s@r.RK 10/19 jpQ:/ '}, {'id': 27, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6oGADWn/ X@z.GV hbA:/ 08/14 '}, {'id': 28, 'aweme_id': None, 'short_url': 'https://v.douyin.com/i6oGD9oo/ 09/24 I@v.SL WMW:/ '}] |
| | | asyncio.run(transform(url_list)) |
| | | while True: |
| | | try: |
| | | url_list = grad_post_dao.get_post_info() |
| | | logger.info(f'查询到待处理数据: {len(url_list)}条') |
| | | asyncio.run(transform(url_list)) |
| | | time.sleep(600) |
| | | except Exception as e: |
| | | logger.error(e) |