Excel web query can it be automated ?

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

Excel web query can it be automated ?

Postby Captain Sensible » Tue May 01, 2007 1:08 pm

My guess is yes but was hoping to avoid hours of work if someone has already written something similar. Basically I'm trying to set up an automated sheet that'll track the sporting life odds against the betfair shows. the url is in the format

http://localhost/sp/scrape.php?url=http ... _1640.html

and I'd want it to pick up the odds about a minute before the off.

I have a few snippets of code collected that'll run macros at preset times just need the mechanics of running the webquery. I guess I could just record a macro and then add that code to the script ?

I can add the day quite easily by sticking that within my php so that's not a problem and I guess I can strip the time and course from cell A1 and use either a lookup script against betfair abbreviations list or parse it using my php so gettung Bath 1st May - 16:40 5f Listed in the correct format shouldn't be a problem. Has anyone automated webqueries within excel ?
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby Captain Sensible » Tue May 01, 2007 1:13 pm

seems edit post has been taken away. So what I'm looking for is a way of passing cell A1 to a webquery about a minute from the off in the format http:/localhost/whatever.php?url=A1 where A1 contains the contents of that cell
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby Mitch » Tue May 01, 2007 1:19 pm

I'm trying to do a similar thing in VB.Net and I'm using http://www.sportinglife.com/racing/liveshows to strip all the url's for the days racing from.

I just need to find out how to send my info to Excel now.

I've never tried running a webquery from Excel other than a quick experiment when I had no idea what I was doing, and it seemed very slow.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby Mitch » Tue May 01, 2007 1:21 pm

Out of curiosity, what is the localhost/scrape/php bit in the address all about? Is it quicker than using the address I mentioned?
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby Mitch » Tue May 01, 2007 1:25 pm

Damn the EDIT POST button being missing!! lol

What I meant by my first post was that you could get the list of races/url's from the address I mentioned into a seperate worksheet then run a macro to see which race is next and use the url direct from that rather than trying to construct it.

I hope that makes more sense to you than it does to me reading it back to myself!
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby Ian » Tue May 01, 2007 1:35 pm

Dunno if this helps or not but this code works for picking up a URL from col one in the active cell's row

MyURL = "URL;" & Cells(ActiveCell.Row, 1).Value

With Workbooks("????????").Sheets("???????")

With .Range("A1").QueryTable

.Connection = MyURL
.WebTables = "9"
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False

End With

End With
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby Captain Sensible » Tue May 01, 2007 2:21 pm

Mitch wrote:Out of curiosity, what is the localhost/scrape/php bit in the address all about? Is it quicker than using the address I mentioned?


I used to use php for my own bots before BA came along so have a lot of scripts lying around - basically the http://localhost bit is just my own pc acting as a server to run php scripts. The script just parses the info stripping out everything other than the horse and odds. Plus it does little things like converting to decimal and removing apostrophes brackets etc so I can then use it alongside the BF odds using vlookup. I don't need to stirp the liveshow menu as the url's are always in the same format and should easily be recreated from the info in cell A1.

I don't find the webqueries that slow from sportinglife mitch maybe you should look at them again rather than using VB to cut and paste it. Soemtimes the SP server can be slow though and that maybe one of the reasons. I don't scrape it to often so no need for a quick refresh.
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby Captain Sensible » Tue May 01, 2007 2:25 pm

Grrr damn edit.....

Ian VB is all above me I'm afraid I just need something to pass the value in A1 to a web query , I can let my php script do the hard work of recreating the actual page to strip

http:/localhost/whatever.php?url=contents of A1
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby GeorgeUK » Tue May 01, 2007 3:11 pm

Captain, probably not what you're looking for, but 1 line of code can open the webpage in a new workbook.

workbooks.open Range("A1").text

This should open a new workbook, but also copies all the extra links and also graphics.
Can't test anything right now as work is starting to crack down on excessive internet use and monitoring webpages visited.

I don't know - some people... eh?

let me know if this is what you need, or if you are just looking for the table with the odds data.
I'll have a look tonight once i get home.

George
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby tkp » Tue May 01, 2007 4:50 pm

Captain - yes it can be automated.

Use the macro recorder to record you setting up a web query.

I've got a few I use to get tips from websites, strip out the time,meeting and then back or lay accordingly (or used to until the website changed format the other day!).

Automating the webquery is quite easy - it's the parsing which is a little more involved.
tkp
User avatar
tkp
 
Posts: 213
Joined: Fri Nov 18, 2005 8:41 pm
Location: Midlands

Postby Captain Sensible » Tue May 01, 2007 5:21 pm

Luckily I've a bit of php knowledge so I route the sp page via that and everything is nicely parsed for me :)

I'll give it a go now before the next lot of racing starts - never seems to be enough time in the day at the moment.
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby Captain Sensible » Tue May 01, 2007 5:42 pm

I managed to automate this far but unable to enter the contents of A10 into the url by pasting when recording the macro. Does anyone with VB knowledge know how I can get the contents of A10 added to the line

"URL;http://localhost/sp/scrape.php?url=", Destination:=Range("A1"))

so it would read as something like

"URL;http://localhost/sp/scrape.php?url=Sedge 1st May - 17:45 2m4f Mdn Hrd", Destination:=Range("A1"))


Sub Macro4()
Range("A10").Select
Selection.Copy
Sheets("sp").Select
Range("A1").Select
Application.CutCopyMode = False
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://localhost/sp/scrape.php?url=", Destination:=Range("A1"))
.Name = "start"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.refresh BackgroundQuery:=False
End With
End Sub
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby GeorgeUK » Tue May 01, 2007 7:19 pm

"URL;http://localhost/sp/scrape.php?url=" & Range("A10").text & ", Destination:=Range("A1"))
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby GeorgeUK » Tue May 01, 2007 7:23 pm

oops (where is that darn edit button?)

not sure, but after the range A10 part, you may need to add in another inverted comma.
I'd walk through using F8 just to make sure.

With this data you're putting into A1, will it not overwrite the urls you have on the sheet?
Just thought i'd ask.
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby Captain Sensible » Tue May 01, 2007 8:05 pm

Thanks George I'll give it a go. They're aren't any url's stored on the sheet - The A10 and A1 refer to separate worksheets

Range("A10").Select
Selection.Copy
Sheets("sp").Select
Range("A1").Select
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Next

Return to Discussion

Who is online

Users browsing this forum: No registered users and 63 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.