I have been trying to scrape a specific page for a couple of days, to no avail. I am a noob both in scraping, and Python.
I am really looking for the last, large table of the page, but there aren't IDs to rely on, so I tried to scrape all tables.
I came up with this code:
import requests
import urllib.request
from bs4 import BeautifulSoup
url = "https://www.freecell.net/f/c/personal.html?uname=Giampaolo44&submit=Go"
r = requests.get(url)
r.raise_for_status()
html_content = r.text
soup = BeautifulSoup(html_content,"html.parser")
tables = soup.findAll("table")
for table in tables:
row_data = []
for row in table.find_all('tr'):
cols = row.find_all('td')
cols = [ele.text.strip() for ele in cols]
row_data.append(cols)
print(row_data)
With the above, I get a massive set of garbage in the print output (*), which was my standard output for two days.
(*) i.e.:
['12/155:27\xa0pm8x4\xa05309-6Streak4:07Won12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', '5:27\xa0pm8x4\xa05309-6Streak4:07Won12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', '8x4\xa05309-6Streak4:07Won12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', 'Streak4:07Won12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', '4:07Won12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', 'Won12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', '12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', '5:23\xa0pm8x4\xa013396-6Streak2:49Won', '8x4\xa013396-6Streak2:49Won', 'Streak2:49Won', '2:49Won', 'Won'], ['12/155:23\xa0pm8x4\xa013396-6Streak2:49Won', '5:23\xa0pm8x4\xa013396-6Streak2:49Won', '8x4\xa013396-6Streak2:49Won', 'Streak2:49Won', '2:49Won', 'Won']]