我是C#编码的新手,我已经在互联网上搜索过以访问网站,并在下面找到:
WebClient myClient = new WebClient();
Stream response = myClient.OpenRead("http://www.contoso.com/index.htm");
// The stream data is used here.
response.Close();
但是如何获取所有网站内容并将其存储在字符串中以访问具有特定内容的特定字段,我已经在excel上使用VBA进行了以下操作:
'link is the rule to get waybill number data from NPTS website
'this website is just a sample (just for clarify the situation)
Link = "URL;http://companyInternalWebsite.com/data=" & Worksheets("Storage_Fees").Range("F6").Value
With Worksheets("NPTS").QueryTables.Add(Connection:=Link, Destination:=Worksheets("NPTS").Range("A1"))
.BackgroundQuery = False
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
'create NPTS data in MyArray
For c = 0 To 12
For r = 0 To 1000
NPTSArray(r, c) = Worksheets("NPTS").Range("A1").Offset(r, c)
Next r
Next c
在VBA中,我复制了所有网站结果内容并将其粘贴到单独的Excel工作表中,然后将所有工作表存储到数组中以分析具有特定内容的特定数据,有没有办法在C#中做到这一点?感谢您的帮助,
致谢,