fixed a problem with homepage by parsing lists better

This commit is contained in:
Tyler Hodapp 2018-02-07 05:09:47 +00:00
parent e26886e858
commit b418771218
2 changed files with 6 additions and 10 deletions

View File

@ -223,7 +223,7 @@ async def on_message(message):
if message.content.startswith('!homepage'): if message.content.startswith('!homepage'):
await client.send_message( await client.send_message(
message.channel, message.channel,
wallpaper.get_picture(message.content) wallpaper.get_picture()
) )
if message.content.startswith('!docker'): if message.content.startswith('!docker'):

View File

@ -30,16 +30,12 @@ def get_wall(message):
else: else:
return response return response
def get_picture(find): def get_picture():
url = requests.get("http://fuckinghomepage.com") url = requests.get("http://fuckinghomepage.com")
soup = BeautifulSoup(url.content) soup = BeautifulSoup(url.content)
soup.prettify(formatter=None) for pic in soup.find_all("p"):
for parse in soup.find_all("p"): if 'SWEET-ASS PICTURE' in ''.join(pic.findAll(text=True)):
if 'SWEET-ASS PICTURE' in ''.join(parse.findAll(text=True)): link = pic.find_next_sibling('p')
link = parse.find_next_sibling('p')
if "http://" or "https://" in link.get('href', ''): if "http://" or "https://" in link.get('href', ''):
link = link.find('small').find_next('a', href=True)['href'] link = link.find('small').find_next('a', href=True)['href']
return urllib.parse.unquote(link.split('http://t.umblr.com/redirect?z=')[1].split('&')[0]) return urllib.parse.unquote(link.split('=')[1].split('&')[0])