[Python] Trying to scrape projections from PrizePicks

Discussão em 'Python' iniciado por Stack, Setembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I am currently trying to streamline my projection model process by scraping the projections from PrizePicks. I keep running into an error that says Invalid Syntax. Any help would be greatly appreciated. Here is my code

    import requests
    import pandas as pd
    pp_props_url = 'https://api.prizepicks.com/projections?league_id=7&per_page=250&single_stat=true'
    headers = {
    'Connection': 'keep-alive',
    'Accept': 'application/json; charset=UTF-8',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
    'Access-Control-Allow-Credentials': 'true',
    'Sec-Fetch-Site': 'same-origin',
    'Sec-Fetch-Mode': 'cors',
    'Referer': 'https://app.prizepicks.com/',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'en-US,en;q=0.9'


    }

    response = requests.get(url=pp_props_url, headers=headers).json()
    player_prop = response
    player_prop
    columns_list = [
    "League",
    "League_Id",
    "Market",
    "Name",
    "Position",
    "Team",
    "Team_Name"
    "Stat_Type"
    "Line_Score",
    "Points",
    "Rebounds",
    "Assists",
    "Pts+Rebs+Asts",
    "3-Pt Made"


    ]

    pp_df = pd.DataFrame(player_prop, columns = columns_list)
    pp_df.to_csv('player_props_20221030.csv', index=False)


    When I open the csv the only thing printed are the column headers. BRAND NEW to this web scraping deal, so I am truly grateful for any help.

    Continue reading...

Compartilhe esta Página