list comprehension
This commit is contained in:
parent
5abddc620e
commit
96c1462acc
@ -27,21 +27,17 @@ class Games(commands.Cog):
|
||||
async def get_ffxiv_worlds(ctx: discord.AutocompleteContext):
|
||||
url = "https://na.finalfantasyxiv.com/lodestone/worldstatus/"
|
||||
|
||||
# Send an HTTP GET request to the URL
|
||||
response = requests.get(url)
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
|
||||
# Find all elements with class "world-list__world_name"
|
||||
world_name_elements = soup.find_all(class_="world-list__world_name")
|
||||
|
||||
# Initialize an empty list to store the contents of the elements
|
||||
worlds = []
|
||||
|
||||
# Loop through each element and extract its contents
|
||||
for element in world_name_elements:
|
||||
# Extract the text content of the element
|
||||
element_content = element.get_text(strip=True)
|
||||
worlds.append(element_content)
|
||||
worlds = [
|
||||
element.get_text(strip=True)
|
||||
for element in soup.find_all(class_="world-list__world_name")
|
||||
]
|
||||
|
||||
return worlds
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user