-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoddshark_scraper.py
56 lines (51 loc) · 1.47 KB
/
oddshark_scraper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python3
import re
import requests
import json
from bs4 import BeautifulSoup
import lxml
r = requests.get(
'https://io.oddsshark.com/ticker/nfl',
headers = {
'referer': 'https://www.oddsshark.com/nfl/scores'
}
)
links = [
(
t["event_date"],
t["away_name"],
t["home_name"],
"https://www.oddsshark.com{}".format(t["matchup_link"]),
t["away_odds"],
t["home_odds"],
t["total"]
)
for t in r.json()['matchups']
if t["type"] == "matchup"
]
for t in links:
if "2018-11-25" in t[0]:
date = t[0]
awayteam = t[1]
hometeam = t[2]
gamelink = t[3]
awayspread = t[4]
homespread = t[5]
overunder = t[6]
r = requests.get(gamelink)
soup = BeautifulSoup(r.content, "lxml")
trends = [
json.loads(v.text)
for v in soup.findAll('script', {"type":"application/json", "id":"gc-data"})
]
print("\n#########################################")
print("{} - {} vs {} => {}\n".format(date, awayteam, hometeam, gamelink))
print("O/U:", overunder, "\n")
for side in ['away','home']:
(team,spread) = (awayteam,awayspread) if side == 'away' else (hometeam, homespread)
rawTrends = trends[0]["oddsshark_gamecenter"]["trends"][side]
print (team, "(", spread, ")", side, "Trends")
for rawTrend in rawTrends:
parsedTrend = rawTrend["value"]
if re.search("over|under", parsedTrend, re.IGNORECASE):
print (parsedTrend)