Scrape/parse webpages in VBA, looking for certain values inside tags and store inside a column

kogia

New Member
Joined
Nov 29, 2011
Messages
3
I have xls file, with many phonenumbers in column A. Can be different amount, so a loop is needed.
08100100
08199999
08199919

<tbody>
</tbody>

Those together with the string: http://personer.eniro.se/resultat/
will find a web page. Eg http://personer.eniro.se/resultat/0810000
Each web page with corresponding phonenumber will have certain information that i would like imported in column B, C, D and so on - next to its corresponding phonenumber. The span-tags and classes of interest (or the values in the tags, here as ?-marks):
class="given-name">????<
class="family-name">???????<
class="street-address">????????<
class="postal-code">??????<
class="locality">??????<
class="geo">????<
class="latitude">??.??????<
class="longitude">??.??????<

Some will not find a web page, since the phonenumber is not registered, in that case it would be nice if each column was given a string; notFound. Also if any web page result wont have eg 2 of the above, like the latitude and longitude.

How can this be done? The computers who should be running this VBA have very limited access or none to install any library or software. It needs to be able to do this from a Windows XP OS with already installed MS Excel 2010 installed.

Any ideas?
 
Last edited:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I'm not that great with DOM in VBA etc. so as a workaround I use an addin by Niels Bosma: Download SeoTools for Excel | Niels Bosma (no installation or admin rights required, just activate the add-in through Excel options). With it comes a formula called XpathOnURL.

Once activated enter the class name in the header (e.g. B1 = given-name)
Then insert this formula into B2:
=XPathOnUrl("http://personer.eniro.se/resultat/"&A2,"//span[@class='"&B$1&"']")

If there's an easy way to do this without any addin,I'd be interested in that solution, too!
Happy scraping.
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,260
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top