Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Net;
- using System.IO;
- namespace TeHead
- {
- class EasyWeb
- {
- public WebResponse resp = null;
- public static string RespStr = null;
- public static string GET(string URI)
- {
- WebRequest req = null;
- WebResponse resp = null;
- try
- {
- req = WebRequest.Create(URI);
- resp = req.GetResponse();
- }
- catch
- {
- return null;
- }
- Stream stream = resp.GetResponseStream();
- StreamReader sr = new StreamReader(stream);
- string Out = sr.ReadToEnd();
- sr.Close();
- RespStr = Out;
- return Out;
- }
- public static string POST(string URI, string Data)
- {
- WebRequest req = WebRequest.Create(URI);
- WebResponse resp = null;
- req.Method = "POST";
- req.Timeout = 100000;
- req.ContentType = "application/x-www-form-urlencoded";
- byte[] sentData = Encoding.GetEncoding(1251).GetBytes(Data);
- req.ContentLength = sentData.Length;
- Stream sendStream = req.GetRequestStream();
- sendStream.Write(sentData, 0, sentData.Length);
- sendStream.Close();
- try
- {
- resp = req.GetResponse();
- }
- catch (WebException ex)
- {
- resp = ex.Response as HttpWebResponse;
- }
- Stream ReceiveStream = resp.GetResponseStream();
- StreamReader sr = new StreamReader(ReceiveStream, Encoding.UTF8);
- Stream stream = resp.GetResponseStream();
- string Out = sr.ReadToEnd();
- sr.Close();
- RespStr = Out;
- return Out;
- }
- public static void SetProxy(string Addr, int Port)
- {
- WebRequest.DefaultWebProxy = new WebProxy(Addr, Port);
- }
- public static string LastResult()
- {
- return RespStr;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement