Raghav 005
Raghav 005

Reputation: 3

how to put web scraped data into a list

this is the code I used to get the data from a website with all the wordle possible words, im trying to put them in a list so I can create a wordle clone but I get a weird output when I do this. please help

import requests
from bs4 import BeautifulSoup


url = "https://raw.githubusercontent.com/tabatkins/wordle-list/main/words"
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
word_list = list(soup)

Upvotes: 0

Views: 133

Answers (1)

HedgeHog
HedgeHog

Reputation: 25048

It do not need BeautifulSoup, simply split the text of the response:

import requests

url = "https://raw.githubusercontent.com/tabatkins/wordle-list/main/words"
requests.get(url).text.split()

Or if you like to do it wit BeautifulSoup anyway:

import requests
from bs4 import BeautifulSoup
url = "https://raw.githubusercontent.com/tabatkins/wordle-list/main/words"
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
soup.text.split()

Output:

['women',
'nikau',
'swack',
'feens',
'fyles',
'poled',
'clags',
'starn',...]

Upvotes: 1

Related Questions