从网页读取实时数据 [英] Read real time data from web page

查看:225
本文介绍了从网页读取实时数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好专家,

我想要C ++/.NET中的程序,该程序将从给定的网页中读取实时数据并将其发布在屏幕上.

即,它应每2秒钟左右刷新一次网页,并应捕获新数据.

如果有任何机构可以对此提供指导,那将是很大的帮助.

谢谢.

Hello experts,

I want program in C++/.NET which will read real-time data from given web page and publish it on screen.

i.e. It should refresh web-pages in every 2 sec or so and should capture new data.

It would be great help , if any body can give pointers on this.

Thanks.

推荐答案

您需要构建一个屏幕抓取引擎.一种简单的方法是使用WebClient(.net后面的代码)类,该类可以帮助您向所需的页面发出http请求.响应包含html或文本.然后,您只需要通过搜索文本模式来解析该html.

您也可以使用ajax(jquery)进行相同的操作.下载HTML并将其加载到dom中.这可以允许您使用jquery来获取要定位的元素(div/table等).这种方法的诀窍是仅显示所需元素的innerHtml/文本,并丢弃文档的其余部分.

希望对您有所帮助.
You need to build a screen scraper engine. A simple one is to use the WebClient (code behind .net) class which can help you make a http request to the page you need. The response contains the html or text. You then just need to parse that html by searching for a text pattern.

You could also do the same using ajax (jquery). Download the html load it in the dom. This can allow you to use jquery to get the element (div/table etc) you are targeting. The trick in this approach is to only display the innerHtml/text of the element you need and discard the rest of the document.

hope this helps.


这篇关于从网页读取实时数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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