用程序怎么实现抓取别人网页上的数据呢?
见标题,如果有源程序或者教程可以发我邮箱:512187557@qq.com谢谢大家了! --------------------编程问答-------------------- 1.利用HttpWebRequest 或者 WebClient 得到网页源码
2.DOM分析或者正则匹配数据
2.输出 --------------------编程问答--------------------
+1 --------------------编程问答-------------------- http://download.csdn.net/detail/json1204/4425176 --------------------编程问答--------------------
protected void Page_Load(object sender, EventArgs e)--------------------编程问答--------------------
{
var arr = HttpGet("http://topic.csdn.net/u/20120712/15/8496f3a7-d837-411c-ae2d-6954379e10a3.html");
Response.Write(arr);
}
/// <summary>
/// HTTP GET方式请求数据.
/// </summary>
/// <param name="url">URL.</param>
/// <returns></returns>
public string HttpGet(string url)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
//request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.Timeout = 15000;
request.AllowAutoRedirect = false;
WebResponse response = null;
string responseStr = null;
try
{
response = request.GetResponse();
if (response != null)
{
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
responseStr = reader.ReadToEnd();
reader.Close();
}
}
catch (Exception)
{
throw;
}
finally
{
request = null;
response = null;
}
return responseStr;
}
谢谢,我现在正在用myeclpise打开,不知道,这个是软件呢,还是源代码呢? --------------------编程问答--------------------
亲,我看不懂喔。 --------------------编程问答--------------------
哈哈哈,太深奥了。我果然丢东西丢的太多了!!
补充:.NET技术 , C#