1. #1
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    Help when scraping from covers

    figured it out nvm
    Last edited by rfr3sh; 10-27-10 at 08:07 AM.

  2. #2
    Borat38
    Borat38's Avatar Become A Pro!
    Join Date: 10-15-10
    Posts: 177
    Betpoints: 132

    How? I'm currently scraping everything manually, finished one season of NBA in 2 days. Still too much work to do, because I bet on 6 other sports.

  3. #3
    Flying Dutchman
    Floggings continue until morale improves
    Flying Dutchman's Avatar Become A Pro!
    Join Date: 05-17-09
    Posts: 2,467
    Betpoints: 759

    you guys interested in sharing? We can spread the pain, and shorten the data build up time to allow for more capping.

  4. #4
    gameday10
    gameday10's Avatar Become A Pro!
    Join Date: 01-16-09
    Posts: 601
    Betpoints: 378

    I'm interested also. Just need teams, half scores and closing line. I'm currenty using covers also but having to look day by day at scores. Would love to scrape it and possible write something for what I'm doing instea of doing it all by hand.

  5. #5
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    well I'm kind of cheating
    but its still not to bad
    just go to the previous scores and select the year you want to scrape...then highlight the table of data copy it,paste special in excel and select unicode

  6. #6
    Maverick22
    Maverick22's Avatar Become A Pro!
    Join Date: 04-10-10
    Posts: 807
    Betpoints: 58

    What the think tank needs is a resident programmer for hire.

    I sure could have used one.. Still do.

  7. #7
    Borat38
    Borat38's Avatar Become A Pro!
    Join Date: 10-15-10
    Posts: 177
    Betpoints: 132

    Quote Originally Posted by rfr3sh View Post
    well I'm kind of cheating
    but its still not to bad
    just go to the previous scores and select the year you want to scrape...then highlight the table of data copy it,paste special in excel and select unicode
    That is how I'm doing it. How long did it take you to finish an entire NBA season? My Excel sheets are laid out exactly in the Covers.com format.

    Maybe we guys can help each other out by farming out one season of each sport to one person. Two people would be needed for NCAAB and NCAAF; there's too many teams and games every season as compared to the NBA.

  8. #8
    Borat38
    Borat38's Avatar Become A Pro!
    Join Date: 10-15-10
    Posts: 177
    Betpoints: 132

    Forgot to mention: I'm intent on putting every season from 2006 to the present from the ff: NBA, WNBA, NFL, CFL, NCAAB, NCAAF, NHL.

  9. #9
    Wrecktangle
    Wrecktangle's Avatar Become A Pro!
    Join Date: 03-01-09
    Posts: 1,524
    Betpoints: 3209

    On many for these same sports I have dbs that extend much further back than 2006 or so. If you are interested in cross-compairing or swapping, let me know.

  10. #10
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    I stopped collecting these sports. going to focus on a small market for a chance to win

  11. #11
    uva3021
    uva3021's Avatar Become A Pro!
    Join Date: 03-01-07
    Posts: 537
    Betpoints: 381

    Here, this is an excel macro that grabs the NFL box scores from covers, copy and paste to excel VBA and run

    Code:
    Sub NFLbox_Covers()
    '
    'This code grabs the NFL box scores from Covers starting from the first game in Week 1 through Week 7
    '
    
    '
    On Error Resume Next
    Dim numend As Long
    Dim numstart As Long
    
    Dim n As Long
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
     
    numend = 27894 'This corresponds to the desired starting data that fits the Covers.com linking structure
    numstart = 27791 'Links are number sequentially from a starting point to an ending point by increments of +1
    
    'Begin loop from numend to numstart
    For n = numend To numstart Step -1
    Worksheets.Add().Name = n 'Add sheet upon initiating each loop
    Sheets(n).Select
    
    'URL parameters to grab an NFL box score -- URL = "covers.com/sports/odds/linehistory.aspx?eventId=" & n & "&sport=nfl&t=0"
    
     With ActiveSheet.QueryTables.Add(Connection:= _
            "URL;covers.com/pageLoader/pageLoader.aspx?page=/data/nfl/results/2010-2011/boxscore" & n & ".html&t=0" _
            , Destination:=Range("$A$1"))
            .Name = n
            .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 = True
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
       
    ' iSub Clean () -- obtrusive data from sheet
    
    Dim myCell As Range
    Dim myRange As Range
    Dim LastRow As Long
    Dim myCell1 As Range
    
    Set myCell1 = Range("A1")
        Cells.Find(What:="Print Sheet", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False).Activate
            Set myCell = ActiveCell
           
            Set myRange = Range(myCell, myCell1)
            myRange.EntireRow.Delete
    LastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
    Set myCell1 = Range("A" & LastRow)
        Cells.Find(What:="NFL Boxscores", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False).Activate
            Set myCell = ActiveCell
           
            Set myRange = Range(myCell, myCell1)
            myRange.EntireRow.Delete
    With Range("A2", Cells(Rows.Count, 1).End(xlUp))
    .SpecialCells(xlCellTypeBlanks, xlTextValues).EntireRow.Delete
    End With
    Next n
        Application.ScreenUpdating = True
        Application.Calculation = xlCalculationAutomatic
    
    End Sub
    Last edited by uva3021; 10-29-10 at 03:01 PM.
    Points Awarded:

    rfr3sh gave uva3021 6 SBR Point(s) for this post.


  12. #12
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    uva, the code just created a bunch of workbooks for me

  13. #13
    Borat38
    Borat38's Avatar Become A Pro!
    Join Date: 10-15-10
    Posts: 177
    Betpoints: 132

    a bit of digression: which sports do you guys think is the most stat-friendly? For me, it's NFL totals and NBA 2H covers, esp dogs.

  14. #14
    uva3021
    uva3021's Avatar Become A Pro!
    Join Date: 03-01-07
    Posts: 537
    Betpoints: 381

    workbooks or worksheets?

    it is working fine for me, make sure u copy and paste the code exactly

  15. #15
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    Worksheets sorry
    and I did paste it exactly with excel 2007

  16. #16
    gameday10
    gameday10's Avatar Become A Pro!
    Join Date: 01-16-09
    Posts: 601
    Betpoints: 378

    I am looking for nba 09-10 schedule with half scores or quarter scores. I have the nba 2h lines/totals already. Just would like to have the scores to possibly write code instead of doing this by hand.

  17. #17
    Optional
    Optional's Avatar Moderator
    Join Date: 06-10-10
    Posts: 57,796
    Betpoints: 9194

    quote=rfr3sh;7138211]uva, the code just created a bunch of workbooks for me[/quote]

    The URL in the code is wrong if you copy paste it as is. "http://www.covers.com/pageLoader/pag...-2011/boxscore"

    I still have the same issue after correcting URL to "http://www.covers.com/pageLoader/pageLoader.aspx?page=/data/nfl/results/2010-2011/boxscore" though... so I guess the forum formatting has broken something else in the code too maybe?

    Not sure why it worked for Uva though. So maybe we have older versions of Excel that don't support the code.

  18. #18
    uva3021
    uva3021's Avatar Become A Pro!
    Join Date: 03-01-07
    Posts: 537
    Betpoints: 381

    ok i understand, didn't notice the faulty URL, for the URL property enter:

    Code:
    "URL;covers.com/pageLoader/pageLoader.aspx?page=/data/nfl/results/2010-2011/boxscore" & n & ".html&t=0"
    Last edited by uva3021; 10-31-10 at 12:51 AM.

  19. #19
    dvsbmx
    dvsbmx's Avatar Become A Pro!
    Join Date: 03-30-10
    Posts: 320
    Betpoints: 966

    After changing the link I'm still getting blank worksheets.

  20. #20
    uva3021
    uva3021's Avatar Become A Pro!
    Join Date: 03-01-07
    Posts: 537
    Betpoints: 381

    The url gets cut short when i post, how about i just attach the file
    Attached Files
    Points Awarded:

    pedro803 gave uva3021 20 SBR Point(s) for this post.


  21. #21
    Borat38
    Borat38's Avatar Become A Pro!
    Join Date: 10-15-10
    Posts: 177
    Betpoints: 132

    blank spreadsheet

    still got a blank spreadsheet from the zip file...

  22. #22
    pedro803
    pedro803's Avatar Become A Pro!
    Join Date: 01-02-10
    Posts: 309
    Betpoints: 5708

    I ran the zip file and it worked for me! Don't know what could be wrong Borat. Thank You so very much UVA -- I am hoping I can use this to see what is wrong with some of my stuff, or just adapt it to some websites I want to scrape.

    Really appreciate it UVA!

  23. #23
    threeg5
    All In A Days Work
    threeg5's Avatar Become A Pro!
    Join Date: 07-18-09
    Posts: 488
    Betpoints: 321

    ok folks how about openoffice to cheap to have excel
    i know they run similar but not exact i have not tried it but any thoughts I am bout to run out the door and will check back in a bit.s

  24. #24
    gamecock0118
    gamecock0118's Avatar Become A Pro!
    Join Date: 10-26-10
    Posts: 9
    Betpoints: 458

    This is awesome and a huge help. I am just starting to attempt to gather data efficiently to hopefully backtest some theories.

  25. #25
    Wrecktangle
    Wrecktangle's Avatar Become A Pro!
    Join Date: 03-01-09
    Posts: 1,524
    Betpoints: 3209

    I'm still interested in some sort of data sharing group, BTW I have data sets on almost every sport that I use for trade.

  26. #26
    benjy
    Untitled
    benjy's Avatar Become A Pro!
    Join Date: 02-19-09
    Posts: 2,158
    Betpoints: 2882

    Quote Originally Posted by Borat38 View Post
    still got a blank spreadsheet from the zip file...
    To get it to work you have to run the macro. Be sure you're showing the developer tab (Excel button, excel options, popular, click box "show developer tab") and then run the macro (Alt+F8 to show all macros).

  27. #27
    gamecock0118
    gamecock0118's Avatar Become A Pro!
    Join Date: 10-26-10
    Posts: 9
    Betpoints: 458

    You should also increase the numend = "#" as the season goes along to have the most up to date data. I could just send you the file after the macro has been run, but then you would never know how to update it.

    I'd probably be interested in trading data, but this is my first shot at this so I don't have any others to trade!

  28. #28
    benjy
    Untitled
    benjy's Avatar Become A Pro!
    Join Date: 02-19-09
    Posts: 2,158
    Betpoints: 2882

    Quote Originally Posted by gamecock0118 View Post
    You should also increase the numend = "#" as the season goes along to have the most up to date data. I could just send you the file after the macro has been run, but then you would never know how to update it.

    I'd probably be interested in trading data, but this is my first shot at this so I don't have any others to trade!
    Thanks for the coding hint.

    I'm in the same boat as gamecock - I'm starting to scape and willing to trade or datacheck but I don't have anything to trade (yet).

  29. #29
    pedro803
    pedro803's Avatar Become A Pro!
    Join Date: 01-02-10
    Posts: 309
    Betpoints: 5708

    same here, I am still trying to learn to scrape, but of course I would be more than happy to trade and share, but alas tengo nada

  30. #30
    demens
    Square -910
    demens's Avatar Become A Pro!
    Join Date: 10-22-10
    Posts: 2,785
    Betpoints: 1258

    Quote Originally Posted by benjy View Post
    To get it to work you have to run the macro. Be sure you're showing the developer tab (Excel button, excel options, popular, click box "show developer tab") and then run the macro (Alt+F8 to show all macros).
    Did this solve anyones issues?

    I'm testing this out and i keep getting blank worksheets (formatted thou) like people were saying before. The URLs are correct and i tried the zip file as well. I'm running the macro. But i can't find the show developer tab option in Excel 10.

    I think the issue may be with security settings, digging through that now.

  31. #31
    uva3021
    uva3021's Avatar Become A Pro!
    Join Date: 03-01-07
    Posts: 537
    Betpoints: 381

    Inside the code, insert a ' before "On Error Resume Next", then post the error message that pops up

  32. #32
    demens
    Square -910
    demens's Avatar Become A Pro!
    Join Date: 10-22-10
    Posts: 2,785
    Betpoints: 1258

    Quote Originally Posted by uva3021 View Post
    Inside the code, insert a ' before "On Error Resume Next", then post the error message that pops up
    Runtime error 9

    Subscript out of range.

    Sheets(n).Select is highlighted in debug mode.

    (using excel btw)
    A bit off topic note. I got the nbaplay-offs sheet with that per2line function to work in oo. Just copied the code (from excel) into the standard module for all worksheets. The weird thing is that when i tried to copy that same code only for that worksheet it would not work.

  33. #33
    brewers7
    brewers7's Avatar Become A Pro!
    Join Date: 03-11-06
    Posts: 298
    Betpoints: 4441

    Quote Originally Posted by gameday10 View Post
    I am looking for nba 09-10 schedule with half scores or quarter scores. I have the nba 2h lines/totals already. Just would like to have the scores to possibly write code instead of doing this by hand.
    I have anything you need from the 2009-10 NBA season...Shoot me a PM and I can get you that if you still need it...

  34. #34
    Nick@SI
    Nick@SI's Avatar Become A Pro!
    Join Date: 09-08-12
    Posts: 33
    Betpoints: 738

    Would anyone know how if its possible to use the numend & numstart across multiple macros? Or maybe a more effective method? I currently have 3 one does the scores for each period then 2 others do the home and road stats and I'd rather not have input the the variable in all 3 far from an expert but pretty good at modifying to fit my needs. I have included the spreadsheet if anyone decides to help. Thanks in advance
    Attached Files

  35. #35
    yak merchant
    yak merchant's Avatar Become A Pro!
    Join Date: 11-04-10
    Posts: 109
    Betpoints: 6170

    Quote Originally Posted by Nick@SI View Post
    Would anyone know how if its possible to use the numend & numstart across multiple macros? Or maybe a more effective method? I currently have 3 one does the scores for each period then 2 others do the home and road stats and I'd rather not have input the the variable in all 3 far from an expert but pretty good at modifying to fit my needs. I have included the spreadsheet if anyone decides to help. Thanks in advance

    Not 100% sure I'm answering what you are asking, but if the macros are run separately then the best way would to be to set up a "Setup" worksheet and type them into a field (let's say A1 and C1), and then have each macro pick up the values from that sheet.

    i.e.


    numstart = Worksheets("Setup").Range("$A$1").Value
    numend = Worksheets("Setup").Range("$C$1").Value


    If you want to string all of the Macros together you can build a master macro that calls all the others and declare the variables in that macro and then pass those as parameters into the the three macros you have.

    Hope that helps.

12 Last
Top