This repository provides an updated function to scrape and collect up ASIN codes of Amazon together with the product names related to the provided keyword.
Download the file asin_check2.py. If you work on Jupyter put it in the repository where you have your main .ipynb file. Then type:
from asin_check2 import asin_lookup2
The usage is simple. Just type asin_lookup2("product_name")
.
asin_lookup2("airpods"):
Clean the dataset whereby necessary.
The file called amazonscraperclass.py provides a more compact way to perform the task. Specifically it defines a class AmazonASINScraper
with an attribute called get_first_three_asins
which returns the name of the product and the first 3 non missing ASIN for the product search input.
scraper = AmazonASINScraper()
df = pd.DataFrame({'Name': ['Airpods', 'Echo', 'Kindle']}) # Example DataFrame
df['ASINs'] = df['Name'].apply(scraper.get_first_three_asins)
print(df)