Septzzz's picture
Upload folder using huggingface_hub (part 26)
0bd6ccf verified
Raw
History Blame Contribute Delete
3.14 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def get_amazon_product_details(productid: str, api_key: str=None, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"This endpoint get the general product description of any amazon product."
productid: This endpoint get the general product description of any amazon product.
"""
url = f"https://abiola-amazon-data-scraper.p.rapidapi.com/products/{productid}"
querystring = {}
if api_key:
querystring['api_key'] = api_key
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "abiola-amazon-data-scraper.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def get_amazon_product_reviews(productid: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"This endpoint gives you the review of the product id you enter."
"""
url = f"https://abiola-amazon-data-scraper.p.rapidapi.com/products/{productid}/reviews"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "abiola-amazon-data-scraper.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def get_amazon_product_offer(productid: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"This endpoint gets the offer of any amazon product."
"""
url = f"https://abiola-amazon-data-scraper.p.rapidapi.com/products/{productid}/offers"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "abiola-amazon-data-scraper.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def get_amazon_search_results(searchquery: str, api_key: str=None, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"This endpoint allows you to search any amazon product description by typing the name of the product."
"""
url = f"https://abiola-amazon-data-scraper.p.rapidapi.com/search/{searchquery}"
querystring = {}
if api_key:
querystring['api_key'] = api_key
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "abiola-amazon-data-scraper.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation