Excel Web Query II (Zvonko)

Here you helped me with a web query a couple weeks ago:

http://www.experts-exchange.com/Web/Web_Languages/Q_20534512.html

I would like to pull the following information off of this site:

http://www.ivolatility.com/options.j?ticker=blud&R=0&top_lookup__is__sent=1

I need to get into a cell using the same method you showed me before:

Average option volume
Average option open interest
IV index call (current)
IV index call (52 week high)
IV index call (52 week low)
IV index put (current)
IV index put (52 week high)
IV index put (52 week low)

now i tried to do it i used the yahoo page pretty well, the <$> eyecatcher just isn't working with this site.

Can you see if you can get it to pull this information?








OptionsMMAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
Hello,

The problem is that you can not nominate the content by eye catcher but by cell number.

I have tested the new functionality with this Excel content:
A1: http://www.ivolatility.com/options.j?ticker=blud&R=0&top_lookup__is__sent=1
B1: 172
C1: 173
D1: 202
E1: 205
F1: 206
G1: 208
H1: 211
I1: 212

Here the code:


Sub getURLdata()
Dim nextURL As String
Dim webResponse As String
Dim nextCell As String
Dim i As Integer
Dim j As Integer
   For i = 1 To 3
       nextURL = Cells(i, 1).Value
       If (nextURL = "") Then Exit For
       webResponse = GetWebContent(nextURL, "", "")
       If (webResponse > "") Then
          For j = 2 To 12
             nextCell = Cells(i, j).Value
             If (nextCell = "") Then Exit For
             MsgBox ExtractCellData(webResponse, CInt(nextCell))
          Next
       End If
   Next
End Sub


Function GetWebContent(ByVal URL As String, ByVal UserID As String, ByVal Password As String) As String
  Dim uid As Variant
  Dim pwd As Variant
  Dim xml As Variant
  uid = UserID
  pwd = Password
  Set xml = CreateObject("Microsoft.XMLHTTP")
  Call xml.Open("GET", URL, False, uid, pwd)
  Call xml.Send
  GetWebContent = xml.responseText
End Function
Function ExtractCellData(ByVal textArea As String, ByVal cellNumber As Integer) As String
Dim i As Integer
Dim nextPos As Integer
Dim theCell As String
Dim inTag As Boolean
Dim nextChar As String

    nextPos = 1
    For i = 1 To cellNumber
      nextPos = InStr(nextPos, textArea, "<td") + 3
    Next
    theCell = Mid$(textArea, nextPos, InStr(nextPos, textArea, "</td") - nextPos)
    inTag = True
    For i = 1 To Len(theCell)
       nextChar = Mid$(theCell, i, 1)
       If (nextChar = ">") Then
          inTag = False
       ElseIf (nextChar = "<") Then
           inTag = True
       ElseIf (Not inTag) Then
           ExtractCellData = ExtractCellData + nextChar
       End If
    Next
    nextPos = InStr(ExtractCellData, "&nbsp;")
    Do While (nextPos > 0)
       If (nextPos > 1) Then
        ExtractCellData = Left$(ExtractCellData, nextPos - 1) & _
        Mid$(ExtractCellData, nextPos + 6)
       Else
        ExtractCellData = Mid$(ExtractCellData, 6)
       End If
       nextPos = InStr(ExtractCellData, "&nbsp;")
    Loop
End Function

Good luck,
Zvonko

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZvonkoSystems architectCommented:
Please increase the dimension of nextPos from Integer to Long.

Like this:
  Dim nextPos As Long

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.