C#写新闻小偷的思路...........
哪个帮说一下C#写新闻小偷的思路啊?
或者实现过程~~~代码就不要了。。。
------解决方案--------------------#region 公共方法
/// <summary>
/// 读取指定URL地址,存到指定文件中
/// </summary>
public string Get()
{
string ResponseText = String.Empty;
WebRequest request = WebRequest.Create(this.url);
if (Method != null && Method != String.Empty)
{
request.Method = Method;
}
//使用代理服务器的处理
if(this.proxyState==1)
{
//默认读取80端口的数据
if(this.proxyPort==null)
this.ProxyPort= "80 ";
WebProxy myProxy=new WebProxy();
myProxy = (WebProxy)request.Proxy;
myProxy.Address = new Uri(this.ProxyAddress+ ": "+this.ProxyPort);
myProxy.Credentials = new NetworkCredential(this.proxyAccount, this.proxyPassword, this.ProxyDomain);
request.Proxy = myProxy;
}
//请求服务
if (Method == "POST ")
{
string strPostData = String.Empty;
for (int i = 0; i < PostData.Length; i++)
{
strPostData += PostData[i] + "& ";
}
strPostData = strPostData.TrimEnd( '& ');
byte[] bytePostData = MyEncoding.GetBytes( "? " + strPostData);
Stream postStream = request.GetRequestStream();
postStream.Write(bytePostData, 0, bytePostData.Length);
postStream.Close();
}
System.Net.WebResponse response = request.GetResponse();
//返回信息
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, MyEncoding);
ResponseText = sr.ReadToEnd();
resStream.Close();
sr.Close();
return ResponseText;
}
#endregion
------解决方案--------------------先用WEBCLIENTDATA方法把首页给下载下来,再用正则判断链接,再到新的链接中去下载,最重要的是你那个链接要进得去,还要出得来。