views:

75

answers:

0

I need to pull data from a table on a website. I can easily do this in VBA using the Web Query, but I need to do this in C#. I'm just having some trouble figuring out how to properly convert the code. I got something close, but it's returning HTML with the data. I just want the data. Any help would be great. The block of code giving me issues is below:

Private Function GetData(ByVal theURL As String, ByVal theRow As Integer, ByVal thePosition As Integer, ByVal theColumn As String, ByVal theTable As Integer) 

    With ActiveSheet.QueryTables.Add(Connection:="URL;" + theURL, Destination:=Sheet2.Range(theColumn & theRow + 1))  
        .Name = "op?s=" + Mid(theURL, thePosition + 1) + "_1"  
        .PreserveFormatting = True  
        .AdjustColumnWidth = True  
        .WebTables = theTable  
        .Refresh BackgroundQuery:=False  
    End With

End Function