updated part alerts parsing
This commit is contained in:
parent
28ce89abef
commit
a0243fab2f
15
app.py
15
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user