I've got a sheet with about 120 hyperlinks. Each of those hyperlinks leads to the same type of webpage but has specific data related to that title. I need information about that title from the webpage that that link would lead me to, but I can't figure out how to grab it.
For Example:
Let's say these 2 hyperlinks are on my sheet-
Women's Health
Entertainment
and I know what each mag is rated (by users/voters), but I want to know how many users/voters that rating is based on. This info is available if I just click on the link, but I need it to appear on the same sheet, next to the hyperlink.
I'm thinking I should generate a web-query for each hyperlink, and extract the data from what will end up being the same table in every query, so how would I do that? Is there a better way?
Even a point in the right direction would be greatly appreciated!
I figured it out. The below code locates the "User ratings" text on a webpage.
Code:Dim oSh As Worksheet Dim hyperlink as string Set oSh = Sheets("Temp Query") hyperlink = http://www.blu-ray.com/movies/Transformers-Revenge-of-the-Fallen-Blu-ray/6216/ oSh.Cells.Clear 'this was code I was looking for''''''' With oSh.QueryTables.Add(hyperlink, oSh.Range("A1")) .BackgroundQuery = False .refresh End With ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Set ratingCell = oSh.Range("A1:Z75").Find(" user ratings", LookAt:=xlPart) Set reviewCell = oSh.Range("A1:Z75").Find("User reviews (", LookAt:=xlPart)
Last edited by justinvalle; 12-08-2009 at 01:38 AM. Reason: address Marzuk's issue
Just be aware that using QueryTables.add repeatedly on a worksheet is a bad idea. You will want to reuse the existing QueryTable and change the parameters + refresh to avoid that. Otherwise what is a 40k worksheet will be a couple MB soon.
Good point, Marzuk. I ran into that problem pretty early and just decided to delete the query each time before I created a new one. I edited above.
Grabbing a few strings from each of 100 web pages takes me a couple minutes, with the biggest factor probably being the webpage import/download. I love this new trick I found; can't believe it was so difficult for me to uncover online.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks