Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web Scraping Sportsbook Websites
#5
Here is an example of a webpage I am trying to scrape:
https://pa.sportsbook.fanduel.com/sports/event/820552.3

I would like to get the data from after Neman Grodno (right now it is +135) but that might change. (I can get that no problem because it is the first instance so [0] of my array.

I would also like to get the data from after Neman Grodno under the dropdown Half-Time Result. This position will change from game to game depending on how many bet offers they have.

They both along with every other wager on the page is listed under the class 'selectionprice'

The easiest way that I could see is to setup a variable and populate it with everything after the Keyword in this case "Half-Time Result". Then parse that data again finding the class 'selectionprice' and it should be the first value in the array.
import requests
import csv
from bs4 import BeautifulSoup
import urllib.request
import random
import re
from selenium import webdriver
chrome_path = r"C:\Users\user\Desktop\chromedriver.exe"

HTML_Header = """
<HTML>
<HEAD>
<TITLE>NBA Comparisons</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>NBA Games</H1><BR>
<TABLE cellpadding=10 border=1>
<TR>
<TD col width=150><CENTER>Matchup</CENTER></TD>
<TD col width=150><CENTER>DraftKings</CENTER></TD>
<TD col width=150><CENTER>Fanduel</CENTER></TD>
<TD col width=150><CENTER>Caesars</CENTER></TD>
<TD col width=150><CENTER>BetAmerica</CENTER></TD>
</TR>
"""

HTML_Body = ""

HTML_Footer = "</TABLE></CENTER></BODY></HTML>"

Urls = []
Teams = ''

with open('M:\SportsBooks.csv') as csvfile:
    readCSV = csv.reader(csvfile, delimiter=',')
    for row in readCSV:
        Urls.append(row)

x = 0
y = len(Urls)
print(y)
z = 0
xyz=0

DK_web_FT = [None] * len(Urls)
DK_web_HT = [None] * len(Urls)
FD_web = [None] * len(Urls)


# Open all the webpages
while True:
    DK_web_FT[z] = webdriver.Chrome(chrome_path)
    DK_web_HT[z] = webdriver.Chrome(chrome_path)
    FD_web[z] = webdriver.Chrome(chrome_path)
    DK_web_FT[z].get(str(Urls[x + 1])[2:-2])
    DK_web_HT[z].get(str(Urls[x + 2])[2:-2])
    FD_web[z].get(str(Urls[x + 3])[2:-2])

    x += 4
    z += 1

    # Change to 3 for testing should be y
    if x >= y:
        break


x = 0
z = 0

# Bulk of the programming below to loop until it populates data for every game in the excel sheet.

while True:

    Teams = str(Urls[x])[2:-2]

    # Retrieve the data from the sites
    DK_Content_FT = DK_web_FT[z].page_source
    DK_Content_HT = DK_web_HT[z].page_source
    FD_Content = FD_web[z].page_source

    # Parse the data
    DK_FT = BeautifulSoup(DK_Content_FT, 'html.parser')
    DK_HT = BeautifulSoup(DK_Content_HT, 'html.parser')
    FD = BeautifulSoup(FD_Content, 'html.parser')

    #DK Lines
    DK_Full_Game_Line = DK_FT.find(class_='sportsbook-odds american default-color')
    DK_Half_Game_Line = DK_HT.find(class_='sportsbook-odds american default-color')
    
    #FD Lines
    FD_Full_Game_Line = FD.find(class_='selectionprice')

    # Add to the counter
    x += 4
    z += 1

    if x >= y:
        break
Reply


Messages In This Thread
Web Scraping Sportsbook Websites - by Khuber79 - Mar-23-2020, 03:33 PM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-23-2020, 04:48 PM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-25-2020, 05:28 AM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-25-2020, 06:39 AM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-25-2020, 08:20 AM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-25-2020, 07:10 PM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-25-2020, 07:25 PM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-25-2020, 07:27 PM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-25-2020, 08:51 PM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-26-2020, 03:44 AM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-27-2020, 07:30 PM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-27-2020, 12:24 AM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-27-2020, 05:16 AM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-27-2020, 09:18 AM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-27-2020, 05:09 PM
RE: Web Scraping Sportsbook Websites - by Larz60+ - Mar-27-2020, 09:21 PM
RE: Web Scraping Sportsbook Websites - by Khuber79 - Mar-30-2020, 11:21 PM
RE: Web Scraping Sportsbook Websites - by Whitesox1 - Mar-17-2021, 12:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Webscrapping sport betting websites KoinKoin 3 5,490 Nov-08-2023, 03:00 PM
Last Post: LoriBrown
Thumbs Up Issue facing while scraping the data from different websites in single script. Balamani 1 2,138 Oct-20-2020, 09:56 AM
Last Post: Larz60+
  Can urlopen be blocked by websites? peterjv26 2 3,414 Jul-26-2020, 06:45 PM
Last Post: peterjv26
  Python program to write into websites for you pythonDEV333 3 2,536 Jun-08-2020, 12:06 PM
Last Post: pythonDEV333
  Scraping Websites to post on Telegram kobryan 1 2,666 Oct-19-2019, 07:03 AM
Last Post: metulburr
  Scraping Websites to post on Telegram kobryan 0 3,439 Oct-09-2019, 04:11 PM
Last Post: kobryan
  Scrapping .aspx websites boxingowl88 3 8,275 Oct-10-2018, 05:35 PM
Last Post: stranac
  Scrapper for websites stinger 0 2,383 Jul-20-2018, 02:11 AM
Last Post: stinger
  scraping javascript websites with selenium DoctorEvil 1 3,390 Jun-08-2018, 06:40 PM
Last Post: DoctorEvil
  Email extraction from websites stefanoste78 14 12,184 Aug-18-2017, 09:44 PM
Last Post: stefanoste78

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020