Skip to content

Commit 4fa8c63

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in 029ccbe according to the output from Autopep8. Details: None
1 parent 7ab207e commit 4fa8c63

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Amazon Best Sellers Scraper/script.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import requests
22
from bs4 import BeautifulSoup
33

4+
45
def scrape_amazon_bestsellers(category_url):
56
headers = {
67
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"}
@@ -11,13 +12,15 @@ def scrape_amazon_bestsellers(category_url):
1112
products = soup.find_all('div', class_='zg-item-immersion')
1213

1314
for index, product in enumerate(products, start=1):
14-
title = product.find('div', class_='p13n-sc-truncate').get_text().strip()
15+
title = product.find(
16+
'div', class_='p13n-sc-truncate').get_text().strip()
1517
rank = index
1618
print(f"Rank: {rank}\nTitle: {title}\n")
1719

1820
else:
1921
print("Failed to retrieve data from Amazon.")
2022

23+
2124
if __name__ == "__main__":
2225
category_url = "https://www.amazon.com/Best-Sellers-Electronics/zgbs/electronics/"
2326
scrape_amazon_bestsellers(category_url)

0 commit comments

Comments
 (0)