• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Alternative way instead of piloting IE

Here's the working code for me now
Code:
Sub TSBPA_Search_Bot()
    Dim http        As New XMLHTTP60
    Dim html        As New HTMLDocument
    Dim posts      As Object
    Dim elem        As Object
    Dim trow        As Object
    Dim cel        As Range
    Dim poststr    As String
    Dim lrow        As Long
    Dim x          As Long
    Dim y          As Long

    Sheet2.Cells.ClearContents
    lrow = Sheet1.Range("A" & Rows.Count).End(xlUp).row

    For Each cel In Sheet1.Range("A2:A" & lrow)
        poststr = "LICID=&LNAME=" & cel & "&FNAME=" & cel.Offset(, 1) & "&CLNAME=&CITY=&CNTY=&STATE=&ZIP=&submit=Submit+Search&tsbpa5a5a713dd8e59=tsbpa5a5a713dd8e59&list=fromsel"

        With http
            .Open "POST", "http://www.tsbpa.state.tx.us/php/fpl/indlookup.php", False
            .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
            .setRequestHeader "User-Agent", "Mozilla/5.0"
            .send poststr
            html.body.innerHTML = .responseText
        End With

        Set posts = html.getElementById("results")

        If Not posts Is Nothing Then
            Sheet2.Cells(x + 1, 1) = cel
            Sheet2.Cells(x + 1, 2) = cel.Offset(, 1)

            For Each elem In posts.Rows
                For Each trow In elem.Cells
                    y = y + 1: Sheet2.Cells(x + 1, y + 2) = trow.innerText
                Next trow
                y = 0: x = x + 1
            Next elem
        End If
    Next cel
End Sub

And hope others share their experiences too
Best and Kind Regards Shahin and thanks a lot for your incredible help
 
Thanks a lot but the great job is the first place for you my friend
God bless you and don't forget the main issue :)
 
Back
Top