Пример #1
0
def get_relative_url(endpoint, session):
	URL = "https://sports.bovada.lv{}?json=true".format(endpoint)
	try:
		response = session.get(URL, headers=get_bovada_headers_generic())
	except Exception, e:
		response = None
		return response
Пример #2
0
def get_relative_url(endpoint, session):
    URL = "https://sports.bovada.lv{}?json=true".format(endpoint)
    try:
        response = session.get(URL, headers=get_bovada_headers_generic())
    except Exception, e:
        response = None
        return response
Пример #3
0
def bovada_auth(username, password):
	cookies = {
    'JOINED': 'true',
    'BG_UA': 'Desktop|OS X|10_12_1|Chrome|55.0.2883.95||',
    'ux': 'created=true',
    'ln_grp': '2',
    'LANGUAGE': 'en',
    'ADRUM': 's=1483171346890&r=https%3A%2F%2Fwww.bovada.lv%2F%3F0',
    'has_js': '1',
    'DEFLANG': 'en',
    's_cc': 'true',
    'bsp': '1',
    's_fid': '25EB81C40CBC6670-086F7CF1DDF960B8',
    's_sq': 'bdbovadalv%3D%2526pid%253DbovadaLV%25253AHome%2526pidt%253D1%2526oid%253DLogin%2526oidt%253D3%2526ot%253DSUBMIT',
}
	print 'called'
	if not username and password:
		try:
			username = os.environ["BOVADA_USERNAME"]
		except KeyError:
			raise BovadaException("could not find your bovada username. Did you export it as an environment variable?")
		try:
			password = os.environ["BOVADA_PASSWORD"]
		except KeyError:
			raise BovadaException("Could not find your bovada password. Did you export it as an environment variable?")


	payload = json.dumps({
		"username": username,
		"password":password})
	return requests.post("https://sports.bovada.lv/services/web/v2/oauth/token",
		data=payload,
		cookies=cookies,
		headers=get_bovada_headers_generic())
Пример #4
0
def bovada_auth():
	try:
		username = os.environ["BOVADA_USERNAME"]
	except KeyError:
		raise BovadaException("could not find your bovada username. Did you export it as an environment variable?")
	try:
		password = os.environ["BOVADA_PASSWORD"]
	except KeyError:
		raise BovadaException("Could not find your bovada password. Did you export it as an environment variable?")
	
	payload = json.dumps({
		"username": username, 
		"password":password})
	return requests.post("https://www.bovada.lv/services/web/v2/oauth/token", 
		data=payload, 
		headers=get_bovada_headers_generic())
Пример #5
0
def bind_api(auth_obj, action, *args, **kwargs):
	soccer_matches = []
	basketball_matches = []
	baseball_matches = []
	tennis_matches = []
	rugby_matches = []
	football_matches = []
	try:
		amount_to_deposit = kwargs.pop("amount")
	except KeyError:
		amount_to_deposit = None

	try:
		bets = kwargs.pop("bets")
	except KeyError:
		bets = None

	urls_to_scrape = []
	profile_id = auth_obj._auth["profile_id"]
	access_token = auth_obj._auth["access_token"]
	token_type = auth_obj._auth["token_type"]
	cookies = auth_obj._auth["cookies"]
	if (
		action == "summary" or 
		action=="wallets" or 
		action=="deposit" or 
		action=="balance" or
		action == "bet_history" or
		action == "open_bets" or 
		action == "open_bet_outcome_ids"
		):

		headers = get_bovada_headers_authorization(access_token, token_type)
	else:
		headers = get_bovada_headers_generic()
	
	with requests.Session() as s:
		request = s.get(get_endpoint(action=action, profile_id=profile_id), headers=headers, cookies=cookies)
		if request.status_code == 200:
			if (action == "summary" or 
				action =="wallets" or 
				action=="deposit" or 
				action=="balance" or
				action == "open_bets" or
				action == "bet_history" or
				action == "open_bet_outcome_ids"
				):
				return parse_special_response(request, action=action)
			else:
				query_all_endpoints = find_relative_urls(request, session=s)
				
				for obj in response_objects:
					#this is where we actually get the bovada matches on each page
					try:
						bmatches = parse_response(obj)
					except Exception, e:
						print e
						print "something went wrong parsing the json obj"
					if bmatches:
						for match in bmatches:
							if match.sport == "BASK":
								if (match.home_team_full_name not in [x.home_team_full_name for x in basketball_matches] and
									match.away_team_full_name not in [away_team.away_team_full_name for away_team in basketball_matches]):
										basketball_matches.append(match)


							elif match.sport == "FOOT":
								if(match.home_team_full_name not in [z.home_team_full_name for z in football_matches] and
									match.away_team_full_name not in [t.away_team_full_name for t in football_matches]):
										football_matches.append(match)

							elif match.sport == "BASE":
								if (match.home_team_full_name not in [p.home_team_full_name for p in basketball_matches] and 
									match.away_team_full_name not in [j.away_team_full_name for j in basketball_matches]):
										basketball_matches.append(match)

							elif match.sport == "TENN":
								if (match.home_team_full_name not in [n.home_team_full_name for n in tennis_matches] and
									match.away_team_full_name not in [m.away_team_full_name for m in tennis_matches]):
										tennis_matches.append(match)

							elif match.sport == "RUGU":
								if (match.home_team_full_name not in [s.home_team_full_name for s in rugby_matches] and
									match.away_team_full_name not in [l.away_team_full_name for l in rugby_matches]
									):
										rugby_matches.append(match)
								

							elif match.sport == "SOCC":
								if (match.home_team_full_name not in [g.home_team_full_name for g in soccer_matches] and
									match.away_team_full_name not in [v.away_team_full_name for v in soccer_matches]):
										soccer_matches.append(match)
							else:
								print "cant parse sport or sport is none: ", match.sport
				return {
					"basketball_matches": basketball_matches,
					"baseball_matches": baseball_matches,
					"rugby_matches": rugby_matches,
					"football_matches":football_matches,
					"soccer_matches":soccer_matches,
					"tennis_matches": tennis_matches,
				}
		else:
Пример #6
0
	def __enter__(self, *args, **kwargs):
		"""authenticate ourselves and return """
		self.auth
		self.cookies = self.auth["cookies"]
		self.headers = get_bovada_headers_generic()
		return self
Пример #7
0
def query_login_endpoint():
	return requests.get("https://sports.bovada.lv/websites/services/components/login", headers=get_bovada_headers_generic())
Пример #8
0
def bind_api(auth_obj, action, *args, **kwargs):

    try:
        amount_to_deposit = kwargs.pop("amount")
    except KeyError:
        amount_to_deposit = None

    try:
        bets = kwargs.pop("bets")
    except KeyError:
        bets = None
    soccer_matches = []
    basketball_matches = []
    baseball_matches = []
    tennis_matches = []
    rugby_matches = []
    football_matches = []
    urls_to_scrape = []
    profile_id = auth_obj._auth["profile_id"]
    access_token = auth_obj._auth["access_token"]
    token_type = auth_obj._auth["token_type"]
    cookies = auth_obj._auth["cookies"]
    if (action == "summary" or action == "wallets" or action == "deposit"
            or action == "balance" or action == "bet_history"
            or action == "open_bets" or action == "open_bet_outcome_ids"
            or action == "bet_history_24_hours"
            or action == "bet_history_3_days"):

        headers = get_bovada_headers_authorization(access_token, token_type)
    else:
        headers = get_bovada_headers_generic()

    with requests.Session() as s:
        request = s.get(get_endpoint(action=action, profile_id=profile_id),
                        headers=headers,
                        cookies=cookies)
        if request.status_code == 200:
            if (action == "summary" or action == "wallets"
                    or action == "deposit" or action == "balance"
                    or action == "open_bets" or action == "bet_history"
                    or action == "open_bet_outcome_ids"
                    or action == "bet_history_24_hours"
                    or action == "bet_history_3_days"):
                return parse_special_response(request, action=action)
            else:
                query_all_endpoints = find_relative_urls(request, session=s)
                print(len(all_urls))
                for obj in response_objects:
                    #this is where we actually get the bovada matches on each page
                    try:
                        bmatches = parse_response(obj)
                    except Exception, e:
                        print e
                        print "something went wrong parsing the json obj"
                    if bmatches:
                        for match in bmatches:
                            if match.sport == "BASK":
                                match.sport = "basketball"
                                basketball_matches.append(match)

                            elif match.sport == "FOOT":
                                match.sport = "football"
                                football_matches.append(match)

                            elif match.sport == "BASE":
                                match.sport = "baseball"
                                baseball_matches.append(match)

                            elif match.sport == "TENN":
                                match.sport = "tennis"
                                tennis_matches.append(match)

                            elif match.sport == "RUGU":
                                match.sport = "rugby"
                                rugby_matches.append(match)

                            elif match.sport == "SOCC":
                                match.sport = "soccer"
                                soccer_matches.append(match)
                            else:
                                print "cant parse sport or sport is none: ", match.sport
                return {
                    "basketball_matches": basketball_matches,
                    "baseball_matches": baseball_matches,
                    "rugby_matches": rugby_matches,
                    "football_matches": football_matches,
                    "soccer_matches": soccer_matches,
                    "tennis_matches": tennis_matches,
                }
        else:
Пример #9
0
 def __enter__(self, *args, **kwargs):
     """authenticate ourselves and return """
     self.auth
     self.cookies = self.auth["cookies"]
     self.headers = get_bovada_headers_generic()
     return self
Пример #10
0
def bovada_auth(credentials=None):
    print "called"
    if not credentials:
        try:
            username = os.environ["BOVADA_USERNAME"]
        except KeyError:
            raise BovadaException("could not find your bovada username. Did you export it as an environment variable?")
        try:
            password = os.environ["BOVADA_PASSWORD"]
        except KeyError:
            raise BovadaException("Could not find your bovada password. Did you export it as an environment variable?")
    else:
        try:
            username = credentials["username"]
        except KeyError:
            raise BovadaException("the credentials object passed does not have a username attribute as a key")

        try:
            password = credentials["password"]
        except KeyError:
            raise BovadaException("the credentials object passed does not have a Password attribute as a key")

    payload = json.dumps({"username": username, "password": password})
    return requests.post(
        "https://sports.bovada.lv/services/web/v2/oauth/token", data=payload, headers=get_bovada_headers_generic()
    )
Пример #11
0
def query_login_endpoint():
    return requests.get(
        "https://sports.bovada.lv/websites/services/components/login", headers=get_bovada_headers_generic()
    )