Jump to content

RP Link extractions from Web to EXCEL


Recommended Posts

[Originally posted on MrEXCEL but 'adviced' they get a bit touchy about Betting related questions] Go to RacingPost (http://www.racingpost.co.uk/news/home.sd). Select a previous days Horse Racing results. Select a UK event. The race results for the selected day & course are shown in red. If you right click on each race (there will be 6 or 7 races for each course) and select Properties, a link will be shown similar to "result.sd?race_id=457578&r_date=2008-5-30',800,485,'no','yes','yes')". What I want to do is extract these links for each race at all UK race courses for that day, so that they would be listed one underneath each other in cells A1, A2, A3 etc. etc. so I would have, for example:- result.sd?race_id=457578&r_date=2008-5-30',800,485,'no','yes','yes') result.sd?race_id=457579&r_date=2008-5-30',800,485,'no','yes','yes') result.sd?race_id=457580&r_date=2008-5-30',800,485,'no','yes','yes') Is this possible to do in EXCEL using a Module!!!? Macro, or anything else?? ....... and, of course, if yes, how? Alternatively, rather than going to the 'Results' in RP, go to the 'Cards' and do a similar exercise. Ultimately, I want the UK race_id numbers for each day.

Link to comment
Share on other sites

Re: RP Link extractions from Web to EXCEL This will do what you want. You can do up to 7 days at once. You just need to enter the start and end dates.

Sub RaceDates() Dim startdate, enddate Dim mystart, myend Dim startday, startmonth, startyear Dim endday, endmonth, endyear Dim myURL startdate = InputBox("Enter Start Date as dd/mm/yy") enddate = InputBox("Enter End Date as dd/mm/yy") Application.ScreenUpdating = False Range("A1").Select startday = Format(CInt(Day(startdate)), "00") startmonth = Format(CInt(Month(startdate)), "00") startyear = CInt(Year(startdate)) endday = Format(CInt(Day(enddate)), "00") endmonth = Format(CInt(Month(enddate)), "00") endyear = CInt(Year(enddate)) myURL = "URL;http://www.racingpost.co.uk/horses/result_search.sd?crs=&r_date=&start_search=1&search_title=Title+or+part+of&search_country=GB&search_course=Any" mystart = "&from_day=" & startday & "&from_month=" & startmonth & "&from_year=" & startyear & "" myend = "&until_day=" & endday & "&until_month=" & endmonth & "&until_year=" & endyear With ActiveSheet.QueryTables.Add(Connection:=myURL & mystart & myend, Destination:=ActiveCell) .FieldNames = True .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingAll .WebTables = "8" .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = True .WebDisableDateRecognition = True .WebDisableRedirections = True .Refresh BackgroundQuery:=False End With Cells.Select With Selection .VerticalAlignment = xlBottom .WrapText = False .MergeCells = False End With Columns("A:B").Select Selection.Delete Shift:=xlToLeft Columns("B").Select Selection.Delete Shift:=xlToLeft Range("A1").Select myrows = Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To myrows If Cells(i, 1).Hyperlinks.Count > 0 Then Cells(i, 1).Offset(0, 1).Value = Cells(i, 1).Hyperlinks(1).Address End If Next i Columns("B:B").Select Selection.Replace What:="*horses/", replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Application.screenupdating=True End Sub
I have code that does the rest too (ie. get the results). all the best sumuwin
Link to comment
Share on other sites

This thread has more posts. To see them, you'll need to sign up or sign in.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...