Back to Llama Index

Oxylabs Reader

docs/examples/data_connectors/OxylabsDemo.ipynb

0.14.212.6 KB
Original Source

<a href="https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/data_connectors/OxylabsDemo.ipynb" target="_parent"></a>

Oxylabs Reader

Use Oxylabs Reader to get information from Google Search, Amazon and YouTube. For more information check out the Oxylabs documentation.

python
%pip install llama-index llama-index-readers-oxylabs

In this notebook, we show how Oxylabs readers can be used to collect information from different sources.

Firstly, import one of the Oxylabs readers.

Currently available readers are:

  • OxylabsAmazonSearchReader
  • OxylabsAmazonPricingReader
  • OxylabsAmazonProductReader
  • OxylabsAmazonSellersReader
  • OxylabsAmazonBestsellersReader
  • OxylabsAmazonReviewsReader
  • OxylabsGoogleSearchReader
  • OxylabsGoogleAdsReader
  • OxylabsYoutubeTranscriptReader
python
import os
from llama_index.readers.oxylabs import OxylabsGoogleSearchReader

Instantiate the reader with your username and password.

python
oxylabs_username = os.environ.get("OXYLABS_USERNAME")
oxylabs_password = os.environ.get("OXYLABS_PASSWORD")

google_search_reader = OxylabsGoogleSearchReader(
    oxylabs_username, oxylabs_password
)

Prepare parameters. This example will load the Google Search results for the 'iPhone 16' query with the 'Berlin, Germany' location.

Check out the documentation for more examples.

python
results = google_search_reader.load_data(
    {"query": "Iphone 16", "parse": True, "geo_location": "Berlin, Germany"}
)

print(results[0].text)

More examples

Amazon Product

python
from llama_index.readers.oxylabs import OxylabsAmazonProductReader


amazon_product_reader = OxylabsAmazonProductReader(
    oxylabs_username, oxylabs_password
)

results = amazon_product_reader.load_data(
    {
        "domain": "com",
        "query": "B08D9N7RJ4",
        "parse": True,
        "context": [{"key": "autoselect_variant", "value": True}],
    }
)

print(results[0].text)

YouTube Transcript

python
from llama_index.readers.oxylabs import OxylabsYoutubeTranscriptReader


youtube_transcript_reader = OxylabsYoutubeTranscriptReader(
    oxylabs_username, oxylabs_password
)

results = youtube_transcript_reader.load_data(
    {
        "query": "SLoqvcnwwN4",
        "context": [
            {"key": "language_code", "value": "en"},
            {"key": "transcript_origin", "value": "uploader_provided"},
        ],
    }
)

print(results[0].text)