From a0243fab2f55a33d01310f5fad51abf024f25595 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Mon, 21 Jun 2021 15:16:13 +0100 Subject: [PATCH] updated part alerts parsing --- app.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index cb265f6..195d5d0 100644 --- a/app.py +++ b/app.py @@ -33,7 +33,7 @@ if not token: exit(0) -bot = discum.Client(token=token, log={"console": False, "file": False}) +bot = discum.Client(token=token, log=False) ######################################## # Callbacks @@ -42,7 +42,7 @@ bot = discum.Client(token=token, log={"console": False, "file": False}) def get_soup(url: str): r = requests.get(url) - return BeautifulSoup(r.text) + return BeautifulSoup(r.text, features="lxml") def get_stockinformer_url(url: str) -> str: @@ -60,15 +60,10 @@ def get_partalert_url(url: str) -> str: for a in bs.find_all("a"): if "amazon" in a.text.lower(): - amazon_url = a.get("href") + # remove tags and referrals + amazon_url = a.get("href").split("?")[0] - try: - asin = PARTALERT_ASIN.search(amazon_url).group('asin') - tld = PARTALERT_TLD.search(amazon_url).group('tld') - - ret_url = f"https://amazon{tld}/dp/{asin}" - except Exception as e: - print(f"Exception: {e}") + ret_url = amazon_url return ret_url