Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scrap arbitrage odds -help
#1
Hi there. I have this code which friend of mine gave me as he trying to figure out why this code not working. Basically it should scrap the best arbitrage odds opportunity from website. All it does is giving back text of link of leagues of football or any other sports. But it supposed to give arrbitrage odds opportunity. Here is the code. Im sure you guys will figure it out more than i will. So please if its not hard for you help me with this.
It uses selenium and webdriver which i have.

 import timeimport sysfrom selenium import webdriver ##basic calculations of how the odds stack updef arb(info):	arbs = []	for x in info[1::2]:		arb = ((1.0/x)*100.0)		arbs.append(arb)	total = sum(arbs)	if total == 0:		return	profit = (10.0/(total/100.0))-10.0	bets = list(map(lambda x: (10*x)/total, arbs))	#ignore anything that we can't arbitrage	if total < 99:		print("\n info:")		print info 		print("\n arbs:")		print arbs 		print("\n bets:") 		print bets 		print("\n profit: \n" + str(profit) + "\n") #allow command line arguments if you want to quickly check a specific sport	if len(sys.argv) > 1:	sports = sys.argv[1:]#otherwise use default list of sports to checkelse: 	sports = ['https://www.oddschecker.com/baseball/mlb','https://www.oddschecker.com/football','https://www.oddschecker.com/tennis/atp-rome',	'https://www.oddschecker.com/basketball/nba', 'https://www.oddschecker.com/football/english/premier-league', 'https://www.oddschecker.com/football/english/championship',	'https://www.oddschecker.com/football/english/league-1', 'https://www.oddschecker.com/football/english/league-2', 'https://www.oddschecker.com/football/english/fa-cup',	'https://www.oddschecker.com/football/elite-coupon', 'https://www.oddschecker.com/football/france/ligue-2', 'https://www.oddschecker.com/football/champions-league',	'https://www.oddschecker.com/football/europa-league', 'https://www.oddschecker.com/football/womens-coupon','https://www.oddschecker.com/american-football/nfl',	'https://www.oddschecker.com/australian-rules/afl', 'https://www.oddschecker.com/badminton', 'https://www.oddschecker.com/boxing', 'https://www.oddschecker.com/ufc-mma',	'https://www.oddschecker.com/gaelic-games/gaelic-football','https://www.oddschecker.com/handball/handball-coupon', 'https://www.oddschecker.com/hockey/all-matches',	'https://www.oddschecker.com/rugby-league/match-coupon','https://www.oddschecker.com/rugby-league/handicaps-coupon','https://www.oddschecker.com/rugby-union/match-coupon',	'https://www.oddschecker.com/rugby-union/handicaps-coupon', 'https://www.oddschecker.com/rugby-union/european-champions-cup', 'https://www.oddschecker.com/rugby-union/lions-tour',	'https://www.oddschecker.com/cricket/ipl','https://www.oddschecker.com/ice-hockey/nhl','https://www.oddschecker.com/tennis/itf-futures',	'https://www.oddschecker.com/tennis/challenger-tour','https://www.oddschecker.com/tennis/wta-rome','https://www.oddschecker.com/football/football-coupons/over-under-2.5',	'https://www.oddschecker.com/football/football-coupons/over-under-1.5', 'https://www.oddschecker.com/football/football-coupons/over-under-0.5', 	'https://www.oddschecker.com/football/football-coupons/both-teams-to-score'] driver = webdriver.Chrome('') # Optional argument, if not specified will search path. for sport in sports: 	driver.get(sport)	markets = driver.find_elements_by_class_name('match-on') 	print "\n----------------------------\n" + sport + "\n----------------------------\n"	for m in markets:		match_data = []		infos = m.find_elements_by_tag_name('td')		for i in infos:			if i.get_attribute('data-best-odds'):				match_data.append((i.find_element_by_class_name('fixtures-bet-name').get_attribute('innerHTML')))				match_data.append(float(i.get_attribute('data-best-odds')))		arb(match_data)		 print "finished!"driver.quit() 

[python] import time import sys from selenium import webdriver ##basic calculations of how the odds stack up def arb(info): arbs = [] for x in info[1::2]: arb = ((1.0/x)*100.0) arbs.append(arb) total = sum(arbs) if total == 0: return profit = (10.0/(total/100.0))-10.0 bets = list(map(lambda x: (10*x)/total, arbs)) #ignore anything that we can't arbitrage if total < 99: print("\n info:") print info print("\n arbs:") print arbs print("\n bets:") print bets print("\n profit: \n" + str(profit) + "\n") #allow command line arguments if you want to quickly check a specific sport if len(sys.argv) > 1: sports = sys.argv[1:] #otherwise use default list of sports to check else: sports = ['https://www.oddschecker.com/baseball/mlb','https://www.oddschecker.com/football','https://www.oddschecker.com/tennis/atp-rome', 'https://www.oddschecker.com/basketball/nba', 'https://www.oddschecker.com/football/english/premier-league', 'https://www.oddschecker.com/football/english/championship', 'https://www.oddschecker.com/football/english/league-1', 'https://www.oddschecker.com/football/english/league-2', 'https://www.oddschecker.com/football/english/fa-cup', 'https://www.oddschecker.com/football/elite-coupon', 'https://www.oddschecker.com/football/france/ligue-2', 'https://www.oddschecker.com/football/champions-league', 'https://www.oddschecker.com/football/europa-league', 'https://www.oddschecker.com/football/womens-coupon','https://www.oddschecker.com/american-football/nfl', 'https://www.oddschecker.com/australian-rules/afl', 'https://www.oddschecker.com/badminton', 'https://www.oddschecker.com/boxing', 'https://www.oddschecker.com/ufc-mma', 'https://www.oddschecker.com/gaelic-games/gaelic-football','https://www.oddschecker.com/handball/handball-coupon', 'https://www.oddschecker.com/hockey/all-matches', 'https://www.oddschecker.com/rugby-league/match-coupon','https://www.oddschecker.com/rugby-league/handicaps-coupon','https://www.oddschecker.com/rugby-union/match-coupon', 'https://www.oddschecker.com/rugby-union/handicaps-coupon', 'https://www.oddschecker.com/rugby-union/european-champions-cup', 'https://www.oddschecker.com/rugby-union/lions-tour', 'https://www.oddschecker.com/cricket/ipl','https://www.oddschecker.com/ice-hockey/nhl','https://www.oddschecker.com/tennis/itf-futures', 'https://www.oddschecker.com/tennis/challenger-tour','https://www.oddschecker.com/tennis/wta-rome','https://www.oddschecker.com/football/football-coupons/over-under-2.5', 'https://www.oddschecker.com/football/football-coupons/over-under-1.5', 'https://www.oddschecker.com/football/football-coupons/over-under-0.5', 'https://www.oddschecker.com/football/football-coupons/both-teams-to-score'] driver = webdriver.Chrome('') # Optional argument, if not specified will search path. for sport in sports: driver.get(sport) markets = driver.find_elements_by_class_name('match-on') print "\n----------------------------\n" + sport + "\n----------------------------\n" for m in markets: match_data = [] infos = m.find_elements_by_tag_name('td') for i in infos: if i.get_attribute('data-best-odds'): match_data.append((i.find_element_by_class_name('fixtures-bet-name').get_attribute('innerHTML'))) match_data.append(float(i.get_attribute('data-best-odds'))) arb(match_data) print "finished!" driver.quit()
[python]
Reply
#2
The code above doesn't work because it is not a valid python code.
Reply
#3
(Jul-31-2019, 06:57 AM)fishhook Wrote: The code above doesn't work because it is not a valid python code.

Well it runs the module and gives out something so it works kind of just not what supposed to do..
So maybe if you know the corrections to this code maybe you could help?
Reply
#4
should be like this I hope this time it pastes normaly
import time

import sys

from selenium import webdriver



##basic calculations of how the odds stack up

def arb(info):

	arbs = []

	for x in info[1::2]:

		arb = ((1.0/x)*100.0)

		arbs.append(arb)

	total = sum(arbs)

	if total == 0:

		return

	profit = (10.0/(total/100.0))-10.0

	bets = list(map(lambda x: (10*x)/total, arbs))

	#ignore anything that we can't arbitrage

	if total < 99:

		print("\n info:")

		print info 

		print("\n arbs:")

		print arbs 

		print("\n bets:") 

		print bets 

		print("\n profit: \n" + str(profit) + "\n")



#allow command line arguments if you want to quickly check a specific sport	

if len(sys.argv) > 1:

	sports = sys.argv[1:]

#otherwise use default list of sports to check

else: 

	sports = ['https://www.oddschecker.com/baseball/mlb','https://www.oddschecker.com/football','https://www.oddschecker.com/tennis/atp-rome',

	'https://www.oddschecker.com/basketball/nba', 'https://www.oddschecker.com/football/english/premier-league', 'https://www.oddschecker.com/football/english/championship',

	'https://www.oddschecker.com/football/english/league-1', 'https://www.oddschecker.com/football/english/league-2', 'https://www.oddschecker.com/football/english/fa-cup',

	'https://www.oddschecker.com/football/elite-coupon', 'https://www.oddschecker.com/football/france/ligue-2', 'https://www.oddschecker.com/football/champions-league',

	'https://www.oddschecker.com/football/europa-league', 'https://www.oddschecker.com/football/womens-coupon','https://www.oddschecker.com/american-football/nfl',

	'https://www.oddschecker.com/australian-rules/afl', 'https://www.oddschecker.com/badminton', 'https://www.oddschecker.com/boxing', 'https://www.oddschecker.com/ufc-mma',

	'https://www.oddschecker.com/gaelic-games/gaelic-football','https://www.oddschecker.com/handball/handball-coupon', 'https://www.oddschecker.com/hockey/all-matches',

	'https://www.oddschecker.com/rugby-league/match-coupon','https://www.oddschecker.com/rugby-league/handicaps-coupon','https://www.oddschecker.com/rugby-union/match-coupon',

	'https://www.oddschecker.com/rugby-union/handicaps-coupon', 'https://www.oddschecker.com/rugby-union/european-champions-cup', 'https://www.oddschecker.com/rugby-union/lions-tour',

	'https://www.oddschecker.com/cricket/ipl','https://www.oddschecker.com/ice-hockey/nhl','https://www.oddschecker.com/tennis/itf-futures',

	'https://www.oddschecker.com/tennis/challenger-tour','https://www.oddschecker.com/tennis/wta-rome','https://www.oddschecker.com/football/football-coupons/over-under-2.5',

	'https://www.oddschecker.com/football/football-coupons/over-under-1.5', 'https://www.oddschecker.com/football/football-coupons/over-under-0.5', 

	'https://www.oddschecker.com/football/football-coupons/both-teams-to-score']



driver = webdriver.Chrome('')  # Optional argument, if not specified will search path.



for sport in sports: 

	driver.get(sport)

	markets = driver.find_elements_by_class_name('match-on') 

	print "\n----------------------------\n" + sport + "\n----------------------------\n"

	for m in markets:

		match_data = []

		infos = m.find_elements_by_tag_name('td')

		for i in infos:

			if i.get_attribute('data-best-odds'):

				match_data.append((i.find_element_by_class_name('fixtures-bet-name').get_attribute('innerHTML')))

				match_data.append(float(i.get_attribute('data-best-odds')))

		arb(match_data)		



print "finished!"

driver.quit()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  web scraping football results and odds terrasamba77 2 676 11 hours ago
Last Post: 22206290
  Web scrap --Need help Lizardpython 4 954 Oct-01-2023, 11:37 AM
Last Post: Lizardpython
  I tried every way to scrap morningstar financials data without success so far sparkt 2 8,171 Oct-20-2020, 05:43 PM
Last Post: sparkt
  Web scrap multiple pages anilacem_302 3 3,783 Jul-01-2020, 07:50 PM
Last Post: mlieqo
  Need logic on how to scrap 100K URLs goodmind 2 2,570 Jun-29-2020, 09:53 AM
Last Post: goodmind
  Scrap a dynamic span hefaz 0 2,659 Mar-07-2020, 02:56 PM
Last Post: hefaz
  scrap by defining 3 functions zarize 0 1,834 Feb-18-2020, 03:55 PM
Last Post: zarize
  Skipping anti-scrap zarize 0 1,853 Jan-17-2020, 11:51 AM
Last Post: zarize
  Cannot get selenium to scrap past the first two pages newbie_programmer 0 4,133 Dec-12-2019, 06:19 AM
Last Post: newbie_programmer
  Scrap data from not standarized page? zarize 4 3,242 Nov-25-2019, 10:25 AM
Last Post: zarize

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020