Files
tilde-projects/Code/irc/util/tropes.py
T

15 lines
562 B
Python
Raw Normal View History

2019-03-15 10:20:44 -04:00
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
# These seem to get the same result each time we run them. I think TVTropes
# has some anti-scraping mechanism
def getTrope():
url = "https://tvtropes.org"
html = BeautifulSoup(requests.get(url).content, "html.parser")
return url + html.find('a', { 'class': 'button-random-trope' })['href']
def getMedia():
url = "https://tvtropes.org"
html = BeautifulSoup(requests.get(url).content, "html.parser")
return url + html.find('a', { 'class': 'button-random-media' })['href']