From 3fbc93e3a07ec4761d03dea5d1c00c057d821ad3 Mon Sep 17 00:00:00 2001 From: Abhijit Motekar <109235675+AbhijitMotekar99@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:27:25 +0530 Subject: [PATCH 1/4] Create Checker.md --- Beginner_Projects/Amazon product availbility checker/Checker.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Beginner_Projects/Amazon product availbility checker/Checker.md diff --git a/Beginner_Projects/Amazon product availbility checker/Checker.md b/Beginner_Projects/Amazon product availbility checker/Checker.md new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Beginner_Projects/Amazon product availbility checker/Checker.md @@ -0,0 +1 @@ + From 0522e7f6033e1afca320362df5e1089c37e7953b Mon Sep 17 00:00:00 2001 From: Abhijit Motekar <109235675+AbhijitMotekar99@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:29:53 +0530 Subject: [PATCH 2/4] Add files via upload --- .../amazon.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Beginner_Projects/Amazon product availbility checker/amazon.py diff --git a/Beginner_Projects/Amazon product availbility checker/amazon.py b/Beginner_Projects/Amazon product availbility checker/amazon.py new file mode 100644 index 0000000000..6a52238443 --- /dev/null +++ b/Beginner_Projects/Amazon product availbility checker/amazon.py @@ -0,0 +1,34 @@ +import requests +from bs4 import BeautifulSoup + + +def check_amazon_availability(product_url): + headers = { + "User-Agent": "Your User Agent Here" # Replace with a valid user agent string + } + + try: + response = requests.get(product_url, headers=headers) + response.raise_for_status() + + soup = BeautifulSoup(response.content, "html.parser") + + title = soup.find("span", {"id": "productTitle"}).get_text(strip=True) + availability = soup.find( + "span", {"class": "a-declarative", "data-asin": True} + ).get_text(strip=True) + + if "out of stock" in availability.lower(): + print(f"{title} is currently out of stock on Amazon.") + else: + print(f"{title} is available on Amazon.") + + except requests.exceptions.HTTPError as http_err: + print(f"HTTP error occurred: {http_err}") + except requests.exceptions.RequestException as req_err: + print(f"Request error occurred: {req_err}") + + +if __name__ == "__main__": + product_url = "YOUR_PRODUCT_URL_HERE" + check_amazon_availability(product_url) From 9d9c11999e09f103bac109fcbd734d399509d5d3 Mon Sep 17 00:00:00 2001 From: Abhijit Motekar <109235675+AbhijitMotekar99@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:30:37 +0530 Subject: [PATCH 3/4] Delete Beginner_Projects/Amazon product availbility checker/Checker.md --- Beginner_Projects/Amazon product availbility checker/Checker.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Beginner_Projects/Amazon product availbility checker/Checker.md diff --git a/Beginner_Projects/Amazon product availbility checker/Checker.md b/Beginner_Projects/Amazon product availbility checker/Checker.md deleted file mode 100644 index 8b13789179..0000000000 --- a/Beginner_Projects/Amazon product availbility checker/Checker.md +++ /dev/null @@ -1 +0,0 @@ - From 096ceb0aa751e67f308635a63b036d5032e126b0 Mon Sep 17 00:00:00 2001 From: AbhijitMotekar99 Date: Thu, 31 Oct 2024 06:01:30 +0000 Subject: [PATCH 4/4] updating Project-Structure.md --- Project-Structure.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Project-Structure.md b/Project-Structure.md index e4476c1230..d35c134234 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -215,6 +215,8 @@ * [Models](Automation_Tools/api_dev/models.py) ## Beginner Projects + * Amazon Product Availbility Checker + * [Amazon](Beginner_Projects/Amazon%20product%20availbility%20checker/amazon.py) * Anime Manga Tracker * [Anime Manga Tracker](Beginner_Projects/Anime_Manga_Tracker/Anime_Manga_Tracker.py) * Bmi Calculator