A python package to get amazon product and search data in json form. The package does not require any API keys as it works by scraping the amazon page.
Project description
amazondata
A python package to get amazon product and search data in json form. The package does not require any API keys as it works by scraping the amazon page.
Reference: How To Scrape Amazon Product Details and Pricing using Python
Install
pip install amazondata
Usage
To get Amazon product details from the url, use the following function.
get_product_from_url(url)
from amazondata.product_details_extractor import ProductDetailsExtractor
product_details_extractor = ProductDetailsExtractor()
data = product_details_extractor.get_product_from_url('https://www.amazon.in/dp/B09JSYVNZ2')
print(data)
To get Amazon product details from the ASIN (Amazon Standard Identification Number) code, use the following function.
get_product_from_asin_code(asin_code)
from amazondata.product_details_extractor import ProductDetailsExtractor
product_details_extractor = ProductDetailsExtractor()
data = product_details_extractor.get_product_from_asin_code('B09JSYVNZ2')
print(data)
To get the list of products from search query use the following function
search(query, page)
from amazondata.search_result_extractor import SearchResultExtractor
search_result_extractor = SearchResultExtractor()
data = search_result_extractor.search('perfume for men', 3)
print(data)
NOTE: Optionally, you can pass custom headers
to all these functions. The default headers value is:
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Sec-Fetch-Site": "none",
"Host": "www.amazon.in",
"Accept-Language": "en-IN,en-GB;q=0.9,en;q=0.8",
"Sec-Fetch-Mode": "navigate",
"Accept-Encoding": "gzip, deflate, br",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15",
"Connection": "keep-alive",
"Upgrade-Insecure-Requests": "1",
"Sec-Fetch-Dest": "document",
"Priority": "u=0, i",
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for amazondata-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54b5afcea76c3f1ebf04fe2dac45c68280ea73b320b565e0a33efd96c17b27ff |
|
MD5 | 91540e0d4100e184f0566fc15da00f63 |
|
BLAKE2b-256 | 943f0d98299b7d00ab42d9e36b6a9203ee8a15afd4e1a2c02ca14798845a136c |