?
Solved

Excel Web Query II (Zvonko)

Posted on 2003-03-17
2
Medium Priority
?
175 Views
Last Modified: 2010-04-06
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?








0
Comment
Question by:OptionsMM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 1000 total points
ID: 8188628
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 8188703
Please increase the dimension of nextPos from Integer to Long.

Like this:
  Dim nextPos As Long

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question