Esempio n. 1
0
def select_chromium_revision(platform):
    """Grab the current Chromium revision for the specified platform for Pyppeteer."""
    if platform is not None:
        url = 'https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/' + \
            platform + '%2FLAST_CHANGE?alt=media'

        webf = urllib.request.urlopen(url)
        chromium_revision = bytearray(next(webf)).decode()

        print(
            f'If Pyppeteer cannot find Chromium, install rev. {chromium_revision}'
        )
        os.environ['PYPPETEER_CHROMIUM_REVISION'] = chromium_revision
        download_chromium()
Esempio n. 2
0
from nonebot import get_driver, require
from nonebot.adapters.cqhttp import Bot, Event
from nonebot.log import logger
from nonebot.permission import GROUP_ADMIN, GROUP_OWNER, SUPERUSER
from nonebot.rule import Rule
from pydantic import BaseSettings

# 更换 Chromium 下载地址为非 https 淘宝源
os.environ['PYPPETEER_DOWNLOAD_HOST'] = 'http://npm.taobao.org/mirrors'
# os.environ['PYPPETEER_DOWNLOAD_HOST'] = 'http://storage.googleapis.com'
from pyppeteer import launch # 不能删,隔壁 dynamic.py 还要调用的
from pyppeteer.chromium_downloader import check_chromium, download_chromium

# 检查 Chromium 是否下载
if not check_chromium():
    download_chromium()


class BiliAPI():
    def __init__(self) -> None:
        self.default_headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
                    "Chrome/79.0.3945.130 Safari/537.36",
        "Referer": "https://www.bilibili.com/"
        }
        
    async def get(self, url, headers=None, cookies=None):
        if not headers:
            headers = self.default_headers
        async with httpx.AsyncClient() as client:
            r = await client.get(url, headers=headers, cookies=cookies)
def install() -> None:
    """Download chromium if not install."""
    if not check_chromium():
        download_chromium()
    else:
        logging.getLogger(__name__).warning('chromium is already installed.')
Esempio n. 4
0
def install() -> None:
    """Download chromium if not install."""
    if not check_chromium():
        download_chromium()
    else:
        logging.getLogger(__name__).warning('chromium is already installed.')
Esempio n. 5
0
async def command(arguments):
    return chromium_downloader.download_chromium()