//Function1;
private string SendUrl(string Host)
{
string StrReturn = "";
WebResponse result = null;
try
{
WebRequest req = WebRequest.Create(Host);
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
StreamReader sr = new StreamReader(ReceiveStream, encode);
Char[] read = new Char[256];
int count = sr.Read(read, 0, 256);
while (count > 0)
{
String str = new String(read, 0, count);
StrReturn += str;
count = sr.Read(read, 0, 256);
}
}
catch (Exception e)
{
StrReturn += e.ToString();
StrReturn += "找不到请求 URI,或者它的格式不正确";
}
finally
{
if (result != null)
{
result.Close();
}
}
return StrReturn.Trim();
}
string url="http://www.*******";
string strData = SendUrl(url);
string[] strRecs = strData.Trim().Replace("\r\n", "#").Replace("\r", "#").Replace("\n", "#").Replace("\t", "#").Split('#');
if (strRecs.Length > 0)
{
for (int i = 0; i < strRecs.Length; i++)
{
string[] strs = strRecs[i].Replace(" ",",").Split(',');
if (strs.Length == 7)
{
Response.Write(strs[1]+","+strs[2]);
}
}
}
//Function2;
public static void WriteFile(string Path, string Content)
{
try
{
string path = HttpContext.Current.Server.MapPath(Path);
if (System.IO.File.Exists(path) == false)
{
using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.GetEncoding("GB2312")))
{
sw.WriteLine(Content);
sw.Flush();
sw.Close();
}
}
}
catch
{
}
}
private string SendUrl(string Host)
{
string StrReturn = "";
WebResponse result = null;
try
{
WebRequest req = WebRequest.Create(Host);
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
StreamReader sr = new StreamReader(ReceiveStream, encode);
Char[] read = new Char[256];
int count = sr.Read(read, 0, 256);
while (count > 0)
{
String str = new String(read, 0, count);
StrReturn += str;
count = sr.Read(read, 0, 256);
}
}
catch (Exception e)
{
StrReturn += e.ToString();
StrReturn += "找不到请求 URI,或者它的格式不正确";
}
finally
{
if (result != null)
{
result.Close();
}
}
return StrReturn.Trim();
}
string url="http://www.*******";
string strData = SendUrl(url);
string[] strRecs = strData.Trim().Replace("\r\n", "#").Replace("\r", "#").Replace("\n", "#").Replace("\t", "#").Split('#');
if (strRecs.Length > 0)
{
for (int i = 0; i < strRecs.Length; i++)
{
string[] strs = strRecs[i].Replace(" ",",").Split(',');
if (strs.Length == 7)
{
Response.Write(strs[1]+","+strs[2]);
}
}
}
//Function2;
public static void WriteFile(string Path, string Content)
{
try
{
string path = HttpContext.Current.Server.MapPath(Path);
if (System.IO.File.Exists(path) == false)
{
using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.GetEncoding("GB2312")))
{
sw.WriteLine(Content);
sw.Flush();
sw.Close();
}
}
}
catch
{
}
}