This is easy if you use the browser control.But the browser cannot be instantiated because the current thread is not in a single-threaded apartment,so you should use Microsoft HTML Object Library for your parser.Your must add a reference to the Microsoft HTML Object Library and use createDocumentFromUrl method.
using System.Net; using System.Text; WebClient wb = new WebClient(); byte[] pagedata = wb.DownloadData(@url); //转换字符、 string result = Encoding.UTF8.GetString(pagedata);然后分析result
byte[] str1 = sHttpWebClinet.DownloadData(uri);
string strWebText = System.Text.Encoding.Default.GetString(str1);
Int32 i1 = strWebText.IndexOf("<title>") + 7;
Int32 i2 = strWebText.IndexOf("</title>") - 1;
string title = strWebText.Substring(i1, i2 - i1);
//获取<title>内容
http://www.51aspx.com/CV/HouseSpiderSystem/InsApp/WebSearch/Getword.cs.html
我写的代码如下,我下载是下载了,但是里面(d:\123.txt)怎么找我要的数据? WebClient Client = new WebClient();
Stream strm = Client.OpenRead("http://fund3.eastmoney.com/450003.html");
StreamReader sr = new StreamReader(strm);
string line;
while ((line = sr.ReadLine()) != null)
{
StreamWriter sw = new StreamWriter("d:\\123.txt", true, Encoding.GetEncoding("gb2312"));
sw.WriteLine(line);
sw.Close();
}
strm.Close();
用Ajax,
xmlHttpRequest 获取其源代码,然后用正则表达式取出你要的数据,我前面回复过一个主题,类似吧,你看了应该可以看懂的,http://topic.csdn.net/u/20071217/15/07cc8121-5fbd-44ef-bb42-30dca422dbe0.html4楼的回复你看看
httpwebrequest
把它抓下来
2.正则
这两个就行了
using System.Text;
WebClient wb = new WebClient();
byte[] pagedata = wb.DownloadData(@url);
//转换字符、
string result = Encoding.UTF8.GetString(pagedata);然后分析result
xmlHttpRequest 获取其源代码,然后用正则表达式取出你要的数据,我前面回复过一个主题,类似吧,你看了应该可以看懂的, http://topic.csdn.net/u/20071217/15/07cc8121-5fbd-44ef-bb42-30dca422dbe0.html 4楼的回复你看看楼主,我在这里说得很清楚啊,正则中把<form 和/form>替换掉就行了,你又没说你的数字两边是什么相的标记,咋给你写啊
我感觉好像是图片(不知是不是,我是新手,不知对不)