Need to scrape web pages in Excel and then save them and then the next time they refresh need to get the results of the chnages of 20 websites or more

Samroy

New Member
Joined
Mar 17, 2012
Messages
1
Hi My project is to download all the data from a few number of webpages, ex: www.rigzone.com so i have created a Macro to do so.

With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.rigzone.com", _
Destination:=Range("$A$1"))
.Name = "www.rigzone"
.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 = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

The above Macro is working fine for this particular website, however when I am trying to put a different website name in place of the www.rigzone.com its not working again I have to record a second macro for the website.

I want to add all the 20 websites in Sheet 1 column A1:A20 and later on if required i can increase the length from A20 to as much as I want. So for that I used a code:-

Private Sub Extract_Click()
Dim WS As Worksheet
Set WS = ActiveSheet
For Each Cell In WS.Range("A1:A20")
ActiveWorkbook.Worksheets.Add
ThisUrl = "url;" & Cell.Value

With ActiveSheet.QueryTables.Add(Connection:= _
ThisUrl, Destination:=Range("$A$1"))
.Name = "index"
.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 = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Next Cell

End Sub

moz-screenshot.png
In this code I wanted excel to select one by one a website those are listed from column A1:A20. It will take the first website gather all the data add a sheet and store it there and then move on to the next A2 website and do the same as soon as I click the Button named "Extract".

However This code is not working, I am using MS Excel 2010. Please help me out I rally cant understand if all the parameters are same the just by changing the link why is it not running.shaumyabrata@gmail.com Please post your reply or email me with your soultion...I am really in need of a solution please anyone help...Waiting
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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