OZmium Sports Betting and Horse Racing Forums

OZmium Sports Betting and Horse Racing Forums (http://forums.ozmium.com.au/index.php)
-   General Topics (http://forums.ozmium.com.au/forumdisplay.php?f=59)
-   -   Tab api changes (http://forums.ozmium.com.au/showthread.php?t=32280)

ballybeg 25th February 2024 06:23 AM

Tab api changes
 
Has anyone had any luck using the tab api after they made changes recently? Don’t know what the changes were, I just can’t pull data down since Thursday

Shaun 29th February 2024 05:03 PM

I fixed mine with help from Discord, i can post what i was told, i had to make changes to the way i was retrieving data, i was previously using Requests with python but i had to change to Selenium so i could create a browser, the browser runs in headless mode, this is what i was told about the issue.

Quote:
by default the user agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

in headless mode, the user agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/121.0.0.0 Safari/537.36

this contains "HeadlessChrome" which may be blocked, so set the user agent back to the default

options.add_argument("--headless=new")
options.add_argument('--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"')


I know you can use Selenium with excel but i have not done that as yet, here is my python code that gets around this issue.

Quote:
from selenium import webdriver
from selenium.webdriver.common.by import By

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
options.add_argument('--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/121.0.0.0 Safari/537.36"')
driver1 = webdriver.Chrome(options=options)

driver1.get("https://api.beta.tab.com.au/v1/tab-info-service/racing/dates/2024-02-26/meetings/R/NOW/races/1/?jurisdiction=VIC")

data = driver1.find_element(By.XPATH, "/html/body").text
print(data)
driver1.close()

ballybeg 2nd March 2024 04:54 AM

Thanks, UserAgent was the issue

Shaun 2nd March 2024 09:46 AM

Quote:
Originally Posted by ballybeg
Thanks, UserAgent was the issue


Do you use excel to get your info or something else?

ballybeg 3rd March 2024 05:12 PM

I use both vba in Ms Access and vb.net


All times are GMT +10. The time now is 08:31 AM.

Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.