0

I'm trying to figure out a way to extract information from an HTML source using a Visual Basic based application I made in Visual Studio 2010. What I'd like to do is have the system load a webpage (based on an order number) in the background and search for a value that is assigned to an HTML tag and return that value. For example, in the href string below:

href="#" class="lnk11blue" onClick="parent.gotoPage('/oe/cllctrshp_.html?dlvyId=26130700&hdrId=7205902&lineId=21188936&ordLnTyp=FEL SVC LINE','dWnd')">26130700

I want the tool to return the 26130700, either after the "dlvyId=" or at the end of the href. The issue I have is the dlvyId changes with every order, as probably does the hdrId and lineId values, so is there a way to have my program read the value after "dlvyId=" after it locates this string? Or is there a way for the program to read the text after the greater than carat after locating the string?

I'll mess around and see what I can find out (and hopefully post code of some attempts), but any ideas/help in the meantime would be greatly appreciated.

Edit: Thanks to Steve, I've got the function to search a string. However, now I'm having trouble loading the page source. I tried this code below but it doesn't seems to work:

Dim objHttp as object
Dim strURL As String
Dim strText As String
objHttp = CreateObject("MSXML2.ServerXMLHTTP")
strURL = "http://companywebprd.tc.company.com/oe/cllctrord_.html?order_nbr=" &
    RMA_Number.Text & "&customer_id=&po_nbr=&ord_date=&ord_cond=0&ord_kind=0&serial_nbr=&item_id=
    &i_ord_type=&instance=&svcChk=1&custSiteUseId=0&custSiteUseCd=0"
objHttp.Open("GET", strURL, False)
objHttp.Send("")

strText = objHttp.responsetext

Advice? I'll keep searching around as well

3
  • Are you using the browser control? Commented Mar 12, 2014 at 15:43
  • Hi Ron, I am not using browser control, would that be beneficial? I'm not very familiar with that part of VB... Commented Mar 12, 2014 at 15:51
  • Yes. You can navigate to the page you specified below and find the element containing the "href". If you can include the entire "href" element including its Id property (if it has one, but class will do but is more complicated) . I will post an answer. Commented Mar 13, 2014 at 16:56

1 Answer 1

1

This should get you started down the right path...

Sub test()
Const mystring = "href='#' class='lnk11blue' onClick='parent.gotoPage('/oe/cllctrshp_.html?dlvyId=26130700&hdrId=7205902&lineId=21188936&ordLnTyp=FEL SVC LINE','dWnd')'>26130700'"
 If InStr(1, mystring, "dlvyId=") <> 0 Then
    For i = InStr(1, mystring, "dlvyId=") To Len(mystring)
        If Mid(mystring, i, 1) = "&" Then
            Exit For
        End If
    Next i
    MsgBox Mid(mystring, InStr(1, mystring, "dlvyId="), (i - InStr(1, mystring, "dlvyId=")))
 End If
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

Just ran that in Excel as a test, this does pretty much exactly what I wanted to do! Now I just have to get the HTML source side-loaded and I should be good to go. Thanks Steve!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.