Skip to content

Instantly share code, notes, and snippets.

@Breta01
Created February 2, 2025 08:08
Show Gist options
  • Save Breta01/ed879a6d03d5b611d73a359f242f337b to your computer and use it in GitHub Desktop.
Save Breta01/ed879a6d03d5b611d73a359f242f337b to your computer and use it in GitHub Desktop.
Example usage of Amazon scraper
from apify_client import ApifyClient
# Initialize the ApifyClient with your API token
client = ApifyClient("<YOUR_API_TOKEN>")
# Scraping individual products
run_input_individual_products = {
"asins": ["B0BN72FYFG", "B0BN92X6XK"], # Add more ASINs as you like
"ranking": "none",
}
# Or scraping ranking categories
run_input_ranking = {
"ranking": "best_seller", # or "new_release", "most_wished", "movers"
# Below remove categories that you don't need!
"categories": [
"Amazon Devices & Accessories", "Amazon Renewed", "Appliances", "Arts, Crafts & Sewing",
"Audible Books & Originals", "Automotive", "Baby", "Beauty & Personal Care", "Books",
"Camera & Photo Products", "CDs & Vinyl", "Cell Phones & Accessories", "Climate Pledge Friendly",
"Clothing, Shoes & Jewelry", "Collectible Coins", "Computers & Accessories",
"Digital Educational Resources", "Electronics", "Entertainment Collectibles",
"Gift Cards", "Grocery & Gourmet Food", "Handmade Products", "Health & Household",
"Home & Kitchen", "Industrial & Scientific", "Kindle Store", "Kitchen & Dining",
"Movies & TV", "Musical Instruments", "Office Products", "Patio, Lawn & Garden",
"Pet Supplies", "Software", "Sports & Outdoors", "Sports Collectibles",
"Tools & Home Improvement", "Toys & Games", "Unique Finds", "Video Games"
],
}
# Run the Actor and wait for it to finish
# Use either run_input_individual_products or run_input_ranking
run = client.actor("8Ye7PvtjobDZrNMFK").call(run_input=run_input_individual_products)
# Fetch and print Actor results from the run's dataset (if there are any)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment