dragon-bot/app/warframe.py

23 lines
802 B
Python
Executable File

from bs4 import BeautifulSoup
import json
import queue
import requests
import threading
def query_wiki(letter, q: queue.Queue):
"""
returns a list of all ships in the game, which can then be passed to the /ship command for auto complete
"""
# Step through the alphabet, and query each page
url = f"https://warframe.fandom.com/wiki/Category:Mods?from={letter}"
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
# Find the div element with the specified class
div_element = soup.find("div", {"class": "category-page__members"}).find_all("li")
# add them all to the main list
q.put([li.text.strip() for li in div_element if "Category" not in li.text])
return sorted([item for sublist in list(q.queue) for item in sublist])