从特定网站获取数据 [英] Fetch data from a given website

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

问题描述

我想在ASP.NET中创建一个Web服务,从网站每隔一小时左右(存储部分,我得到了它覆盖)获取数据。 在这个例子中,metacritic.com,我怎么能得到用户评分一部电影的任何给定的时间间隔?

I want to create a web service in ASP.NET that fetches data from a website every hour or so (the storing part I got it covered). In this example, metacritic.com, how can I get the Users score of a movie at any given time interval?

我所知道的是,我会得到网站的源,然后找到包含我想要的数据(按名称在最好的情况下)的HTML元素,但我不知道该怎么做

What I know is, I would have to get the source of the website and then find the html element that contains the data I want (by name in the best of the cases) but I don't know how to do it.

在此先感谢您的帮助!

推荐答案

有关事物的HTTP请求的一面, Web客户端可能是最简单的。

For the HTTP request side of things, WebClient is probably the easiest.

对于一个简单的,阻塞的HTTP请求,这样做:

For a simple, blocking HTTP request, do this:

string page = (new WebClient()).DownloadString("http://foo.bar/page");

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

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