Forum Discussion
Scrape Fantasy Baseball Site
- 1 year ago
You might be able to get what you want with this code...
let url = "https://atl-01.statsplus.net/ohbl/draftajax/", formData = "{""info"":""round"",""lid"":""100"", ""round"":""All""}", formDataJson = Text.ToBinary(Uri.BuildQueryString(Json.Document(formData))), response = Web.Contents(url, [Content=formDataJson, Headers=[#"Content-Type"="application/x-www-form-urlencoded"]]), htmlTable = Html.Table(response, {{"Round", "TD:nth-child(1)"}, {"Pick", "TD:nth-child(2)"}, {"Overall", "TD:nth-child(3)"}, {"Team", "TD:nth-child(4)"}, {"Selection", "TD:nth-child(5)"}, {"Column6", ".active .player-name-modal"}, {"Pick Time", "TD:nth-child(6)"}, {"Column8", "SUP"}}, [RowSelector="TD:nth-child(1)"]) in htmlTableHope this points you in the right direction.
You might be able to get what you want with this code...
let
url = "https://atl-01.statsplus.net/ohbl/draftajax/",
formData = "{""info"":""round"",""lid"":""100"", ""round"":""All""}",
formDataJson = Text.ToBinary(Uri.BuildQueryString(Json.Document(formData))),
response = Web.Contents(url, [Content=formDataJson, Headers=[#"Content-Type"="application/x-www-form-urlencoded"]]),
htmlTable = Html.Table(response, {{"Round", "TD:nth-child(1)"}, {"Pick", "TD:nth-child(2)"}, {"Overall", "TD:nth-child(3)"}, {"Team", "TD:nth-child(4)"}, {"Selection", "TD:nth-child(5)"}, {"Column6", ".active .player-name-modal"}, {"Pick Time", "TD:nth-child(6)"}, {"Column8", "SUP"}}, [RowSelector="TD:nth-child(1)"])
in
htmlTable
Hope this points you in the right direction.
Hey jgeddes-
This is exactly what I was looking to do. I very much appreciate you providing the query to complete the task. I was curious of one more thing. In the background I can see in the website source code that it retreives an id (unique identifier) for each player. Is there anyway for me to just look at the raw JSON?
I see this step looks to pull in a CSV. I am somewhat familiar with JSON and could probably parse it. Just curious as this is the one part of data that I'm missing that I don't see rendering on the webpage but I know is there....
In the Page Source Code:
Also, any assistance on the general idea you are using to get the data would be great. It's great that you were able to help, but would like to try to understand what you did at a fundamental level. So I could potentially use it at some point in the future.
Again Thank you already for what you have provided!! This is wonderful!
- jgeddes1 year agoSuper User
I found the api url and form data needed by inspecting the site you provided.
From there I constructed the call with the form data and then formatted the response into a html table.
If you are looking for raw json data my suggestion would be to get the api documentation for the site and adjust the call accordingly.