Bottom Page

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]
Quote
#2
The code above doesn't work because it is not a valid python code.
Quote
#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?
Quote
#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()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Scrap text out of td table from URLS Gochix2020 4 183 Aug-03-2019, 02:56 AM
Last Post: Larz60+
  scrap macrotrends mr_byte31 7 248 Aug-02-2019, 12:02 AM
Last Post: mr_byte31
  i am trying to web scrap this .asp nufan0000 1 203 May-30-2019, 02:27 AM
Last Post: Larz60+
  Scrap Yahoo Finance using BS4 mr_byte31 7 1,350 Aug-24-2018, 02:50 PM
Last Post: Larz60+
  [Hlep]Scrap webiste mr_byte31 2 634 Jul-21-2018, 08:11 PM
Last Post: Larz60+
  beatifulsoup scrap td tag. piuk3man 1 657 Jun-11-2018, 06:16 AM
Last Post: buran
  web scrap currency ikeen 6 1,089 Jun-04-2018, 11:59 AM
Last Post: ikeen

Forum Jump:


Users browsing this thread: 1 Guest(s)