Exemplo n.º 1
0
def check():
    print("[pyppeteer settings]")
    print(f"Chromium version: {__chromium_revision__}")
    print(f"Home drectory: {__pyppeteer_home__}")
    downloaded = "downloaded" if check_chromium() else "not downloaded"
    print(f"Executable: {chromium_executable()} ({downloaded})")

    print()

    print("[DB settings]")
    print(f"SQLite version: {sqlite3.sqlite_version}")
    print(f"SQLite Python library version: {sqlite3.version}")
    print(f"File path: {settings.DATABASE_URL}")
Exemplo n.º 2
0
import nonebot
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:
Exemplo n.º 3
0
def install() -> None:
    """Download chromium if not install."""
    if not check_chromium():
        download_chromium()
    else:
        logging.getLogger(__name__).warning('chromium is already installed.')
Exemplo 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.')
Exemplo n.º 5
0
        download_chromium()


# Make sure Python version is at least 3.6, otherwise do nothing.
if sys.version_info > (3, 5):
    from pyppeteer.chromium_downloader import check_chromium, download_chromium
    from appdirs import AppDirs
    import shutil

    if 'PYPPETEER_CHROMIUM_REINSTALL' in os.environ:
        pyppeteer_chromium_dir = AppDirs(
            'pyppeteer').user_data_dir + '/local-chromium'
        if os.path.isdir(pyppeteer_chromium_dir):
            print("Deleting previous pyppeteer Chromium installation.")
            try:
                shutil.rmtree(pyppeteer_chromium_dir)
            except:
                print(f'Deleting old {pyppeteer_chromium_dir} failed.')
        else:
            print(f'{pyppeteer_chromium_dir} does not exist.')

    if check_chromium():
        print("Chromium already installed, pyppeteer will not download.")
    else:
        select_chromium_revision(current_platform())

    from n2_gui_test import n2_gui_test_case

    if __name__ == "__main__":
        unittest.main()