View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_2_] Don Guillett[_2_] is offline
external usenet poster
 
Posts: 1,522
Default Importing several web pages with macro/VBA?

On Aug 21, 12:46*pm, ron wrote:
Yes, this can be done in a relatively straightforward manner. *I don't think opening IE and scraping the data is the best way to go. *For so many web pages such an approach would take a long time. *A better way might be to use the following construction, it will take the source code behind the web page and assign it to a variable. *You can then use the "instr" and "mid" functions to extract the data you are interested in and place it in your workbook.

* * my_url = "your_url"
* * Set my_obj = CreateObject("MSXML2.XMLHTTP")
* * my_obj.Open "GET", my_url, False
* * my_obj.send
* * my_var = my_obj.responsetext
* * Set my_obj = Nothing

This code would placed inside a loop where you increment the start date by 1
each time through and then use that date to build the next url. *The lop could also contain an if/then/else construction to see if the word "NBA" appears on the current webpage and react accordingly...Ron

==================
Why don't you provide a complete sub or send a file to me at
dguillett1 @gmail.com.
Using the query only takes about 1 second for each date and results
in:

Team Open Line Movements Current Moneyline Scores
NBA 04/21/2007
501 new jersey nets 191 193 / 193.5 / 194 194.5 165 96 Under 194.5
502 toronto raptors -4.5 -14 -4.5 -190 91 final
503 miami heat 183 183 / 182.5 / 183 183.5 175 91 Over 183.5
504 chicago bulls -4.5 -1 -5 -210 96 final
505 orlando magic 180.5 181 / 180.5 / 181 181.5 475 92 Over 181.5
506 detroit pistons -8 -24.65789474 -10 -650 100 final
507 utah jazz 184 188.5 / 189 / 189.5 189 240 75 Under 189
508 houston rockets -6 -20.91666667 -6.5 -280 84 final
NBA 04/22/2007
511 los angeles lakers 214.5 212.5 / 212 / 211.5 212 550 87 Under
212
512 phoenix suns -10.5 -0.090909091 -15.5 -750 95 final
513 denver nuggets 196 196.5 / 197 / 197.5 197 320 95 Under 197
514 san antonio spurs -8 0.941176471 -8 -400 89 final
515 golden state warriors 214.5 214.5 / 215 / 214.5 215 500 97 Under
215
516 dallas mavericks -10 -15.15 -10 -700 85 final
NBA 04/23/2007
701 orlando magic 182.5 182.5 / 183 / 183.5 184 400 90 Over 184
702 detroit pistons -8.5 1.0625 -23 -500 98 final
703 utah jazz 185.5 185 / 184.5 / 185 185.5 190 90 Over 185.5
704 houston rockets -5.5 -0.181818182 -10 -230 98 final
NBA 04/24/2007
705 new jersey nets 194 194 / 194.5 / 194 193.5 200 83 Under 193.5
706 toronto raptors -5 -5.545454545 -20.5 -240 89 final
707 miami heat 184.5 184.5 / 185 / 184.5 184 135 89 Over 184
708 chicago bulls -4.5 -9.408163265 -3 -155 107 final
709 los angeles lakers 208 208 / 207.5 / 208 208.5 380 98 Over 208.5
710 phoenix suns -9.5 -9 -05 / -9 EVEN / -8.5 -14 -480 126 final
NBA 04/25/2007
711 denver nuggets 195 194.5 / 194 / 194.5 194 330 88 Under 194
712 san antonio spurs -8.5 -8.5 -13.5 -420 97 final
715 golden state warriors 210 210.5 / 210 / 209.5 210 425 99 Over
210
716 dallas mavericks -9.5 -14.66620499 -9.5 EVEN -550 112 final
NBA 04/26/2007
501 detroit pistons -2 -20.2 -22.5 -155 93 Under 183
502 orlando magic 183 183 / 183.5 183 135 77 final
503 houston rockets 186 186 / 186.5 / 187.5 188 170 67 Under 188
504 utah jazz -4 -0.222222222 -4.5 -200 81 final
505 phoenix suns -4 -10.25 -24 -190 89 Under 211
506 los angeles lakers 210 210 / 211.5 211 165 95 final
NBA 04/27/2007
507 toronto raptors 192 192 / 191.5 191 165 89 Push 191
508 new jersey nets -4.5 -4.5 -4 -190 102 final
509 chicago bulls 185 185 / 184.5 / 185 185.5 200 104 Over 185.5
510 miami heat -5.5 -5.5 -10.5 -240 96 final
511 dallas mavericks -4.5 -13.875 -4 -180 91 Under 212
512 golden state warriors 211 211 / 211.5 212 160 109