大概是这样一个流程:
1、winform程序中,输入一个查询条件,需要打开一个固定网站,并且模拟点击该网站的查询按钮功能,将输入的查询条件带入并查询。
2、查询出来的结果可以肯定是一个列表,需要模拟挨个点击该列表中的“查看详细信息”按钮功能,点击此按钮后会打开一个详细信息的页面,其中显示的信息的字段是固定的,比如:“申请日”,“申请号”等。
3、需要将对应字段的内容抓取下来,存入数据库中。CS项目做的比较少,现在是一头雾水,求大侠出面,告诉我思路和要用到的技术,越详细越好!
分不够另开贴结算,绝不拖欠!谢谢
1、winform程序中,输入一个查询条件,需要打开一个固定网站,并且模拟点击该网站的查询按钮功能,将输入的查询条件带入并查询。
2、查询出来的结果可以肯定是一个列表,需要模拟挨个点击该列表中的“查看详细信息”按钮功能,点击此按钮后会打开一个详细信息的页面,其中显示的信息的字段是固定的,比如:“申请日”,“申请号”等。
3、需要将对应字段的内容抓取下来,存入数据库中。CS项目做的比较少,现在是一头雾水,求大侠出面,告诉我思路和要用到的技术,越详细越好!
分不够另开贴结算,绝不拖欠!谢谢
下载网页的 类 webclient 类,有个方法下载 指定URL 的源代码只要你需要用的到 正则表达式 来获取相应的 数据,Regex类 会帮你解决之后如果你的匹配数据是 有很多条。就需要循环遍历了
http://blog.csdn.net/adsdassadfasdfasdf/archive/2010/08/23/5831347.aspx
http://zhidao.baidu.com/question/47894569.html
好象是国外某个公司的 ,记不清了,也许是搜狐的。
http://hi.baidu.com/panyuan1988/blog/item/b1904e955538d46154fb96f7.html
自己再用正则表达找出要的信息
昨天后来下班回家了。。所以没有及时关注
今天看了一下,发现各位的重点不是我想表述的
举个例子:
我现在要用cs系统打开百度,并带入搜索条件
然后模拟百度的“百度一下”按钮,点击
在搜索出来的结果列表中,需要点击打开
这个打开后的URL地址我并不知道啊。看了楼上的重点都在网页内容的抓取,现在问题是我怎么拿到这个网页?
{
private static CookieContainer cookie = new CookieContainer();
private static string contentType = "application/x-www-form-urlencoded";
private static string accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight-2-b1, */*";
private static string userAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"; public static string GetHtmlEx(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = userAgent;
request.ContentType = contentType;
request.CookieContainer = cookie;
request.Accept = accept;
request.Method = "get"; WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
Encoding encoding = null;
for (int i = 0; i < response.Headers.Count; i++)
{
Match m = Regex.Match(response.Headers[i].ToString(), "(?i)(?<=charset=)[^ ]+");
if (!m.Success) continue;
encoding = Encoding.GetEncoding(m.Value);
break;
}
StreamReader reader = new StreamReader(responseStream, encoding);
String html = reader.ReadToEnd();
response.Close(); return html;
}
}
string html = WebFunc.GetHtmlEx("网址");