Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 1.03 KB

File metadata and controls

49 lines (37 loc) · 1.03 KB
# Synchronous Example
import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.search.advanced(search_terms=[
        "<value 1>",
        "<value 2>",
        "<value 3>",
    ], sort_by="<value>", next_cursor="")

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
import os
from x_api_scraper import XapiScraper

async def main():

    async with XapiScraper(
        bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
    ) as xapi_scraper:

        res = await xapi_scraper.search.advanced_async(search_terms=[
            "<value 1>",
            "<value 2>",
            "<value 3>",
        ], sort_by="<value>", next_cursor="")

        # Handle response
        print(res)

asyncio.run(main())