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.
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