Skip to content

Commit 253c805

Browse files
committed
Clean up garbage URL
1 parent 9cf114c commit 253c805

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

plugins/amazon.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22
from bs4 import BeautifulSoup
3+
from urllib.parse import urlparse
34

45
from cloudbot import hook
56
from cloudbot.util import web, formatting
@@ -43,6 +44,9 @@ def amazon(text):
4344
except AttributeError:
4445
rating = "No Ratings"
4546

46-
url = web.try_shorten(item.find('a', {'class': 's-access-detail-page'})['href'])
47+
# clean up garbage url
48+
o = urlparse(item.find('a', {'class': 's-access-detail-page'})['href'])
49+
url = o.scheme + "://" + o.netloc + o.path + "?linkCode=as2&tag=cloudbot-20"
50+
url = web.try_shorten(url)
4751

4852
return "\x02{}\x02 ({}) - {} - {}".format(title, price, rating, url)

0 commit comments

Comments
 (0)