Initial
This commit is contained in:
34
python/web/mal_top_fetcher.py
Executable file
34
python/web/mal_top_fetcher.py
Executable 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)
|
||||
Reference in New Issue
Block a user