I'm working on automating a Website to excel copy -paste work. The website here is a government website, so a little tricky to handle. I have a problem in extracting data from this website : http://nhb.gov.in/IndexPage.aspx?enc=nRXYbvwNFTF218kodGo9fg==
Few project codes for trying out are :
- 37TTG0000170
- 28AAP0023256
- 23MP0006837
- 23AMP0006839
I have a list of project codes, which should be taken from the excel file, pasted in the website and then clicked on Verify Button.
Then in the next page the the same project code is hyperlinked, which upon clicking leads us to our results page with information about the project, which is to be extracted and pasted into the excel sheet beside the respective project code, such as those tables and data.(That's a later part which can be tweaked).
I have reached the last result page but finding it difficult to extract stuff out of it.
Option Explicit
Public Sub NHBsite()
Dim bot As WebDriver, Cell As Range
'Dim ws As Worksheet
'Dim rng as Range
Dim count As Long
Const URL As String = "http://nhb.gov.in/IndexPage.aspx?enc=nRXYbvwNFTF218kodGo9fg=="
Set bot = New ChromeDriver
'Set ws = ThisWorkbook.Worksheets("Data")
'Set rng = ws.Range(ws.Range("A2"), ws.Range("A2").End(xlDown))
'bot.Window.Maximize
'For Each Cell In rng
count = 1
While (Len(Range("A" & count)) > 0)
bot.Get URL
bot.FindElementById("ctl00_ContentPlaceHolder1_ctl00_txtProjectCode").SendKeys
Range("A" & count)
bot.FindElementById("ctl00_ContentPlaceHolder1_ctl00_btnSearchProject").Click
bot.FindElementById("ctl00_ContentPlaceHolder1_ctl00_gvSerachDetails_ctl02_lblProjectCode").Click
Range("B" & count) = bot.FindElementById("Table5").Text
count = count + 1
Wend
'bot.Wait 1000
'bot.TakeScreenshot.SaveAs (ThisWorkbook.Path + "/Screenshot_" + Cell.Value +
".jpg")
'Next
bot.Quit
End Sub