How to use the xalpha.provider function in xalpha

To help you get started, we’ve selected a few xalpha examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github refraction-ray / xalpha / tests / test_universal.py View on Github external
def proxy():
    xa.provider.set_proxy("socks5://127.0.0.1:1080")
    yield
    xa.provider.set_proxy()
github refraction-ray / xalpha / tests / test_universal.py View on Github external
def proxy():
    xa.provider.set_proxy("socks5://127.0.0.1:1080")
    yield
    xa.provider.set_proxy()
github refraction-ray / xalpha / tests / test_jq.py View on Github external
import sys

sys.path.insert(0, "../")
import xalpha as xa
import pandas as pd
import pytest
import shutil

xa.provider.set_jq_data(debug=True)


@pytest.fixture
def csv_cache():
    xa.set_backend(backend="csv", path="./")
    yield
    xa.set_backend(backend="memory", path="pytest-")


# 防止peb csv 数字位长反复变化
@pytest.fixture
def reset_table():
    l = ["./peb-SH000807.csv", "./sw-801180.csv", "./teb-SH000300.csv"]
    for f in l:
        shutil.copyfile(f, f + ".backup")
    yield
github refraction-ray / xalpha / xalpha / cons.py View on Github external
def wrapper(*args, **kws):
            import xalpha.provider as xp

            if getattr(xp, "proxy", None):
                kws["proxies"] = {"http": xp.proxy, "https": xp.proxy}
                kws["timeout"] = timeout
                logger.debug("Using proxy %s" % xp.proxy)
            if args:
                url = args[0]
            else:
                url = kws.get("url", "")
            headers = kws.get("headers", {})
            if (not headers.get("user-agent", None)) and (
                not headers.get("User-Agent", None)
            ):
                headers["user-agent"] = "Mozilla/5.0"
            kws["headers"] = headers
            for count in range(tries):
                try:
                    logger.debug(
github refraction-ray / xalpha / xalpha / cons.py View on Github external
def wrapper(*args, **kws):
            import xalpha.provider as xp

            if getattr(xp, "proxy", None):
                kws["proxies"] = {"http": xp.proxy, "https": xp.proxy}
                kws["timeout"] = timeout
                logger.debug("Using proxy %s" % xp.proxy)
            if args:
                url = args[0]
            else:
                url = kws.get("url", "")
            headers = kws.get("headers", {})
            if (not headers.get("user-agent", None)) and (
                not headers.get("User-Agent", None)
            ):
                headers["user-agent"] = "Mozilla/5.0"
            kws["headers"] = headers
            for count in range(tries):
                try:
                    logger.debug(
                        "Fetching url: %s . Inside function `%s`"
                        % (url, inspect.stack()[1].function)
                    )