This commit is contained in:
olari
2019-04-13 22:28:43 +03:00
commit cbf6cd3f07
19 changed files with 1066 additions and 0 deletions

34
python/web/mal_top_fetcher.py Executable file
View File

@@ -0,0 +1,34 @@
import requests, bs4, time
def get_titles(filename, title_type, maxrank):
with open(filename, "w", encoding="UTF-8") as file:
limit = 0
written = 0
while True:
page = requests.get("https://myanimelist.net/topanime.php?type=" + title_type + "&limit=" + str(limit), headers = {'User-agent': 'stopblockingmyscriptlol'})
page.raise_for_status()
soup = bs4.BeautifulSoup(page.text, "html.parser")
titles = soup.select("a[rel]")
for title in titles:
if len(title.text) == 2 or title.text == "Login":
continue
file.write(title.text.strip() + '\n')
written += 1
print(str(written), title.text.strip())
if written >= maxrank:
break
if written >= maxrank:
break
limit += 50
get_titles("rating.txt", "tv", 1750)
get_titles("movies.txt", "movie", 300)