Need Help Scrape City And Ares From Pincode - Web Scraping

babulalgandhi

New Member
Joined
Feb 5, 2015
Messages
12
Hi Friends

The Website "http://www.newkerala.com/pincode/" Is For To Get Place Name From Postal Code

I Made A Macro Which Ask For Pincode And Get Data From Website.
The Result Is In Three Or Four Pages Vary As Per Pincode Input

I Can Get First Page Result Data In Excel From Web Page.
Dont Know How To Implement Code In Excel Macro
To Navigate Next Page And Get Data And Navigate Next Page And Get Data And So On

Here Is My Code Friends

Sub getaddress()
'we define the essential variables
Dim ie As Object
Dim r As Integer, c As Integer, t As Integer
Dim elemCollection As Object
Dim form As Variant, button As Variant

'add the "Microsoft Internet Controls" reference in your VBA Project indirectly
Set ie = CreateObject("InternetExplorer.Application")

'more variables for the inputboxes - makes our automation program user friendly
mypincode = InputBox("Enter Pincode")


With ie

.Visible = True
.navigate ("http://www.newkerala.com/pincode/")

' we ensure that the web page downloads completely before we fill the form automatically
While ie.ReadyState <> 4
DoEvents
Wend

'assigning the vinput variables to the html elements of the form
ie.Document.getElementsByName("keyword").Item.innerText = mypincode

' accessing the button via the form

ie.Document.getElementsByName("Submit2").Item.Click

' again ensuring that the web page loads completely before we start scraping data
Do While ie.busy: DoEvents: Loop


'Clearing any unnecessary or old data in Sheet1
ThisWorkbook.Sheets("Sheet1").Range("A1:K500").ClearContents

Set elemCollection = ie.Document.getElementsByTagName("TABLE")

For t = 0 To (elemCollection.Length - 1)

For r = 0 To (elemCollection(t).Rows.Length - 1)
For c = 0 To (elemCollection(t).Rows(r).Cells.Length - 1)
ThisWorkbook.Worksheets(1).Cells(r + 1, c + 1) = elemCollection(t).Rows(r).Cells(c).innerText
Next c
Next r
Next t

End With

' cleaning up memory
Set ie = Nothing

End Sub



Example Pincodes Are Given Below
110001
110002
110003
110004
110005
110006
110007
110008
110009
110010

The Result Is In Three Or Four Pages Vary As Per Pincode Input

I Can Get First Page Result Data In Excel From Web Page.
Dont Know How To Implement Code In Excel Macro
To Navigate Next Page And Get Data And Navigate Next Page And Get Data And So On

Thanks You For Your Time Spent On Me Helping

Thanks & Regards
Babulal Gandhi
babulalgandhi@gmail.com
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
There is a blatant disclaimer at the bottom of the site's homepage that states "Unauthorised use of any content from this website is strictly prohibited."

I guess they don't want their site being scraped...
 
Upvote 0
Dear S O WXLS Please Show Me Any Site With Out Disclaimer At The Bottom "Unauthorised Use Of Any Content From This Website Is Strictly Prohibited.",

Besides It Is Public Information Not Private. No One Can Go Check Whole Places And Postal Codes. He Or They Also Gathered Information From Other Sites.

By The Way Thanks For Your Opinion

Thanks & Regards
Babulal Gandhi
 
Upvote 0
I Need Area Name And City Name From Postal Code. This Postal Code Is Not House Number. So This Is Not Personal Information
Averagely 400 to 500 Hundred Houses In Single Postal Code Area In India.

For Uk Its PostCode
For Usa Its ZipCode
In India Its PinCode
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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