如何通过从外部网页获取数据来构建VB​​10.0应用程序? [英] How do I build a VB10.0 application by fetching data from an external webpage?

查看:119
本文介绍了如何通过从外部网页获取数据来构建VB​​10.0应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从网页 Current Sch Rev No 5 获取整数数据(例如 5 NERLDC(http://www.nerldc.org/Default.aspx)定期间隔 10秒。用于比较其更改后的值(例如, 5 )与其前面的值(例如, 4 ,显示在10秒后面)以获取我的< u> VB10.0应用程序输出,例如,反映当前状态 说, 值在应用程序中更改了 Value Unchanged )。



请问,有人可以写解决方案吗,怎么做?



注意:(1)只有使用浏览器IE或Mozilla Firefox才能看到整数数据的转换(例如, 5



( 2)此应用程序未链接到任何数据库,仅用于实时应用程序。

解决方案

可能是这样的。



 Dim http As HttpWebRequest = CType(WebRequest.Create(http://www.nerldc.org/Default.aspx,HttpWebRequest)
http.Timeout = 10000'10秒

http.UserAgent =NERLDC
Dim hwr As HttpWebResponse = CType(http.GetResponse,HttpWebResponse)
Dim enc As Encoding = Encoding.GetEncoding(1252 )
Dim rdr as StreamReader = New StreamReader(hwr.GetResponseStream,enc)


Do

Dim line As String = rdr.ReadLine
如果行IsNot Nothing则
'做你需要做的事

'如果它是一个csv文件,请使用下面的行
'Dim s()As String = line.Split(,)
结束如果
Loop Until line is Nothing


I want to fetch the integer data (say, 5) from the string Current Sch Rev No 5 of a webpage NERLDC (http://www.nerldc.org/Default.aspx) in a regular interval of 10 Sec. for comparing its changed value (say, 5) to its preceded value (say, 4, which was shown 10 Sec. back) to obtain subsequent changes in my VB10.0 application output, for example, reflecting the Current Status (say, Value Changed or Value Unchanged) in the application.

Please, can anyone write the solution, how to do that?

N.B.: (1)The transition of integer data (say, 5) is only visible using browsers IE or Mozilla Firefox

(2)This application is not linked to any database, its only for real-time application.

解决方案

Maybe something like this.

Dim http As HttpWebRequest = CType(WebRequest.Create("http://www.nerldc.org/Default.aspx", HttpWebRequest)
http.Timeout = 10000 ' 10 secs

http.UserAgent = "NERLDC"
Dim hwr As HttpWebResponse = CType(http.GetResponse, HttpWebResponse)
Dim enc As Encoding = Encoding.GetEncoding(1252)
Dim rdr as StreamReader = New StreamReader(hwr.GetResponseStream, enc)


Do
						
   Dim line As String = rdr.ReadLine
   If line IsNot Nothing Then
       'Do what you need to do
       
      'if it's a csv file, use the line below
       'Dim s() As String = line.Split(",")	
   End If
Loop Until line Is Nothing


这篇关于如何通过从外部网页获取数据来构建VB​​10.0应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆