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):
|
async def get_ffxiv_worlds(ctx: discord.AutocompleteContext):
|
||||||
url = "https://na.finalfantasyxiv.com/lodestone/worldstatus/"
|
url = "https://na.finalfantasyxiv.com/lodestone/worldstatus/"
|
||||||
|
|
||||||
# Send an HTTP GET request to the URL
|
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
|
|
||||||
# Find all elements with class "world-list__world_name"
|
# Find all elements with class "world-list__world_name"
|
||||||
world_name_elements = soup.find_all(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
|
# Loop through each element and extract its contents
|
||||||
for element in world_name_elements:
|
worlds = [
|
||||||
# Extract the text content of the element
|
element.get_text(strip=True)
|
||||||
element_content = element.get_text(strip=True)
|
for element in soup.find_all(class_="world-list__world_name")
|
||||||
worlds.append(element_content)
|
]
|
||||||
|
|
||||||
return worlds
|
return worlds
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user