# Get amazon product names
def scrape_product_names(asins,csv_path='product_names.csv'):
product_mapping = {}
for asin in asins:
url = f"https://www.amazon.com/dp/{asin}"
response = requests.get(url, data=None, headers= {'User-Agent': 'Mozilla/5.0'})
soup = BeautifulSoup(response.content, 'html.parser')
product_title = soup.find("span", {"id": "productTitle"})
if product_title:
product_name = product_title.get_text().strip()
product_name = product_name.split('|')[0].strip()
product_mapping[asin] = product_name
else:
product_mapping[asin] = asin
return product_mapping
This is the function that I run to get product name from amazon website, but I found that only few name found only and it taking a longer time for running. Is there any recommendation?
Same way I trying to scape image but only few image can got.
Try to get all the product name.