Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Importing Specific Data From Multiple Pages From The Web

Hi,

I am looking for some fancy code that would import data from a
specific site from mutiple pages from within the site. I recorded one
page using the macro recorder, then I went into the code and
manipulated it somewhat, but it is still too manual and to combursome
to work with from a practical point of view.

- The site is www.covers.com
- I want to downlaod all past scorer results for each NCAAB team.
- All the teams can be found at:

http://www.covers.com/pageLoader/pag...ams/teams.html

- There are over 300 teams.
- Each team has a specific page which shows a specific year's results.
I beleive it currently goes as far back as the 1997-1998 season. So
that at least 10 pages per team.

Example of 1 team for a specific year:

http://www.covers.com/pageLoader/pag.../team2518.html

- Ideally I would like a macro to import 50 teams at a time using
their specific team codes to identify the teams. Duke for example =
2518. So I would need an option to enter in the team # first, or if
it's too much code, I can go into the code itself and change it
manually. Output would be the page data + the last cell of each row
would contain the name of the team.

Thanks you.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Importing Specific Data From Multiple Pages From The Web

Just looked at your URL. The first team I see is the UK Wildcats. When I
click on that the URL is
http://www.covers.com/pageLoader/pag.../team2228.html

Notice the 2228.

Then next link is for SU (my alma mater, well one of several), and the URL is
http://www.covers.com/pageLoader/pag.../team2186.html

Notice the 2186

The next link is for OK and the URL is
http://www.covers.com/pageLoader/pag.../team2243.html

Notice the 2243€¦see the pattern here. I cant tell where those 4-digit
numbers are coming from, but if you can find out and put them in a list, in
lets say Column A, you can easily create a sub that loops through each item
in the list as it does the imports of all the data that corresponds to those
4-digit numbers.

Notice my macro for doing something similar to what you are doing (except I
am importing historical stock data):

Sub HistData()

Application.ScreenUpdating = False

Dim str1 As String
Dim c As Range
Dim Stocks As Range
Dim bFound As Boolean
Dim ws As Worksheet

Set Stocks = Application.InputBox( _
"Type 'Symbols' in the input box below", Type:=8)

For Each c In Sheets("Firms, Import").Range("Symbols") €˜< -- the data list
is here, my stock symbol list, your 4-digit codes, etc.

bFound = False
For Each ws In Worksheets
If ws.Name = c.Value Then
bFound = True
Exit For
End If
Next ws

If bFound = False Then
Worksheets.Add.Name = c.Value €˜< -- This creates a new worksheet for
each variable and names the sheet the name of the variable

End If

Sheets(c.Value).Select
Cells.Select
Range("A1:IV65536").ClearContents

str1 = "URL;http://finance.yahoo.com/q/ks?s=" & _
c.Value €˜< -- this c.Value is the variable that changes, i.e. stock
symbol list, your 4-digit codes, etc.

With ActiveSheet.QueryTables.Add(Connection:=str1 _
, Destination:=Range("A1"))

.Name = str1

.Name = "ks?s=c.Value" < -- again, notice the variable; when you
record your macro this part will be totally different€¦you have to choose the
appropriate web tables to import€¦

.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With

End Sub

Just record a macro as you import the data from the web. This will get you
most of what you need. Then, use the first part of this code:
From - Sub HistData()
To - Range("A1:IV65536").ClearContents

Then your recorded code comes in here.

Then this:

Next c
End Sub

Regards,
Ryan--



--
RyGuy


"qcan" wrote:

Hi,

I am looking for some fancy code that would import data from a
specific site from mutiple pages from within the site. I recorded one
page using the macro recorder, then I went into the code and
manipulated it somewhat, but it is still too manual and to combursome
to work with from a practical point of view.

- The site is www.covers.com
- I want to downlaod all past scorer results for each NCAAB team.
- All the teams can be found at:

http://www.covers.com/pageLoader/pag...ams/teams.html

- There are over 300 teams.
- Each team has a specific page which shows a specific year's results.
I beleive it currently goes as far back as the 1997-1998 season. So
that at least 10 pages per team.

Example of 1 team for a specific year:

http://www.covers.com/pageLoader/pag.../team2518.html

- Ideally I would like a macro to import 50 teams at a time using
their specific team codes to identify the teams. Duke for example =
2518. So I would need an option to enter in the team # first, or if
it's too much code, I can go into the code itself and change it
manually. Output would be the page data + the last cell of each row
would contain the name of the team.

Thanks you.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
importing specific data into a new excel spreadsheet AllieR Excel Discussion (Misc queries) 3 January 18th 09 08:16 PM
importing specific cells from multiple workbooks into 1 workbook Walter Davis New Users to Excel 5 June 18th 08 04:15 AM
Importing specific data into an Excel workbook kare9 Excel Worksheet Functions 1 January 6th 07 06:39 PM
Importing data into specific template cells Ron Excel Discussion (Misc queries) 0 July 11th 06 07:24 PM
PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook templa Bing Excel Programming 8 December 27th 04 02:52 PM


All times are GMT +1. The time now is 03:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"