'Webscraping a table from VegasInsider
I'd like to scrape this table from Vegas Insider
I am a total beginner when it comes to web scraping. I have tried a few different ways via stackoverflow but haven't been able to nail it down.
This is as far as I have been able to get.
from bs4 import BeautifulSoup
import requests
source = requests.get('https://www.vegasinsider.com/college-basketball/odds/las-vegas/money/').text
soup = BeautifulSoup(source, "html.parser")
tbl = soup.find('table', class_='frodds-data-tbl')
for matchups in tbl.find_all('td', {'class': ['viCellBg1', 'oddsGameCell','cellTextNorm','cellTextNorm']}):
if matchups.span is not None:
gameDate = matchups.span.text
print(gameDate)
for b_ in matchups.find_all('b'):
print(b_.a.text)
I'd eventually send these results to a CSV and change the column headers to match the book names on the table. Any help here is appreciated.
Solution 1:[1]
If you don't care about the formatting, you can use pd.read_html:
import pandas as pd
url = "https://www.vegasinsider.com/college-basketball/odds/las-vegas/money/"
pd.read_html(url)[7]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rachwa |
