威尼斯人线上娱乐

效仿登录总计,开发总计

11 4月 , 2019  

在开发者界面用能够观察众多ptqrlogin伊始的 name

威尼斯人线上娱乐,smart qqC#开发计算:

威尼斯人线上娱乐 1威尼斯人线上娱乐 2/**//// <summary>  登录
威尼斯人线上娱乐 3        /// </summary>
威尼斯人线上娱乐 4        /// <param name=”url”></param>
威尼斯人线上娱乐 5        /// <param name=”paramList”></param>
威尼斯人线上娱乐 6        /// <returns></returns>
威尼斯人线上娱乐 7        public static string Login(String url, String paramList)
威尼斯人线上娱乐 8威尼斯人线上娱乐 9        威尼斯人线上娱乐 10{
威尼斯人线上娱乐 11            HttpWebResponse res = null;
威尼斯人线上娱乐 12            string strResult = “”;
威尼斯人线上娱乐 13            try
威尼斯人线上娱乐 14威尼斯人线上娱乐 15            威尼斯人线上娱乐 16{
威尼斯人线上娱乐 17                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
威尼斯人线上娱乐 18                req.Method = “POST”;
威尼斯人线上娱乐 19                req.ContentType = “application/x-www-form-urlencoded”;
威尼斯人线上娱乐 20                req.AllowAutoRedirect = false;
威尼斯人线上娱乐 21                CookieContainer cookieCon = new CookieContainer();
威尼斯人线上娱乐 22                req.CookieContainer = cookieCon;
威尼斯人线上娱乐 23                StringBuilder UrlEncoded = new StringBuilder();
威尼斯人线上娱乐 24威尼斯人线上娱乐 25                Char[] reserved = 威尼斯人线上娱乐 26{ ‘?’, ‘=’, ‘&’ };
威尼斯人线上娱乐 27                byte[] SomeBytes = null;
威尼斯人线上娱乐 28                if (paramList != null)
威尼斯人线上娱乐 29威尼斯人线上娱乐 30                威尼斯人线上娱乐 31{
威尼斯人线上娱乐 32                    int i = 0, j;
威尼斯人线上娱乐 33                    while (i < paramList.Length)
威尼斯人线上娱乐 34威尼斯人线上娱乐 35                    威尼斯人线上娱乐 36{
威尼斯人线上娱乐 37                        j = paramList.IndexOfAny(reserved, i);
威尼斯人线上娱乐 38                        if (j == -1)
威尼斯人线上娱乐 39威尼斯人线上娱乐 40                        威尼斯人线上娱乐 41{
威尼斯人线上娱乐 42                            UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, paramList.Length – i)));
威尼斯人线上娱乐 43                            break;
威尼斯人线上娱乐 44                        }
威尼斯人线上娱乐 45                        UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, j – i)));
威尼斯人线上娱乐 46                        UrlEncoded.Append(paramList.Substring(j, 1));
威尼斯人线上娱乐 47                        i = j + 1;
威尼斯人线上娱乐 48                    }
威尼斯人线上娱乐 49                    SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
威尼斯人线上娱乐 50                    req.ContentLength = SomeBytes.Length;
威尼斯人线上娱乐 51                    Stream newStream = req.GetRequestStream();
威尼斯人线上娱乐 52                    newStream.Write(SomeBytes, 0, SomeBytes.Length);
威尼斯人线上娱乐 53                    newStream.Close();
威尼斯人线上娱乐 54                }
威尼斯人线上娱乐 55                else
威尼斯人线上娱乐 56威尼斯人线上娱乐 57                威尼斯人线上娱乐 58{
威尼斯人线上娱乐 59                    req.ContentLength = 0;
威尼斯人线上娱乐 60                }
威尼斯人线上娱乐 61
威尼斯人线上娱乐 62                res = (HttpWebResponse)req.GetResponse();
威尼斯人线上娱乐 63                cookieheader = req.CookieContainer.GetCookieHeader(new Uri(url));
威尼斯人线上娱乐 64                Stream ReceiveStream = res.GetResponseStream();
威尼斯人线上娱乐 65                Encoding encode = System.Text.Encoding.GetEncoding(“GBK”);
威尼斯人线上娱乐 66                StreamReader sr = new StreamReader(ReceiveStream, encode);
威尼斯人线上娱乐 67                Char[] read = new Char[256];
威尼斯人线上娱乐 68                int count = sr.Read(read, 0, 256);
威尼斯人线上娱乐 69                while (count > 0)
威尼斯人线上娱乐 70威尼斯人线上娱乐 71                威尼斯人线上娱乐 72{
威尼斯人线上娱乐 73                    String str = new String(read, 0, count);
威尼斯人线上娱乐 74                    strResult += str;
威尼斯人线上娱乐 75                    count = sr.Read(read, 0, 256);
威尼斯人线上娱乐 76                }
威尼斯人线上娱乐 77            }
威尼斯人线上娱乐 78            catch (Exception e)
威尼斯人线上娱乐 79威尼斯人线上娱乐 80            威尼斯人线上娱乐 81{
威尼斯人线上娱乐 82                strResult = e.ToString();
威尼斯人线上娱乐 83            }
威尼斯人线上娱乐 84            finally
威尼斯人线上娱乐 85威尼斯人线上娱乐 86            威尼斯人线上娱乐 87{
威尼斯人线上娱乐 88                if (res != null)
威尼斯人线上娱乐 89威尼斯人线上娱乐 90                威尼斯人线上娱乐 91{
威尼斯人线上娱乐 92                    res.Close();
威尼斯人线上娱乐 93                }
威尼斯人线上娱乐 94            }
威尼斯人线上娱乐 95            return strResult;
威尼斯人线上娱乐 96        }
威尼斯人线上娱乐 97威尼斯人线上娱乐 98        /**//// <summary>  获取页面HTML
威尼斯人线上娱乐 99        /// </summary>
威尼斯人线上娱乐 100        /// <param name=”url”></param>
威尼斯人线上娱乐 101        /// <param name=”paramList”></param>
威尼斯人线上娱乐 102        /// <returns></returns>
威尼斯人线上娱乐 103        public static string getPage(String url, String paramList)
威尼斯人线上娱乐 104威尼斯人线上娱乐 105        威尼斯人线上娱乐 106{
威尼斯人线上娱乐 107            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
威尼斯人线上娱乐 108            req.Headers[“If-None-Match”] = “36d0ed736e88c71:d9f”;
威尼斯人线上娱乐 109            req.Referer = “”;
威尼斯人线上娱乐 110            CookieContainer cookieCon = new CookieContainer();
威尼斯人线上娱乐 111            req.CookieContainer = cookieCon;
威尼斯人线上娱乐 112            req.CookieContainer.SetCookies(new Uri(url), cookieheader);
威尼斯人线上娱乐 113            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
威尼斯人线上娱乐 114            StreamReader sr = new StreamReader(res.GetResponseStream(),Encoding.Default);
威尼斯人线上娱乐 115            string strResult = sr.ReadToEnd();
威尼斯人线上娱乐 116            sr.Close();
威尼斯人线上娱乐 117            return strResult;
威尼斯人线上娱乐 118        }

威尼斯人线上娱乐 119

整整开发下来其实有些都不是很难,从一开首二维码
获取到终极的收发消息,基本上都以效仿浏览器的操作。都以依照http通信。一下正是本次新手学习http协议的最要紧的叁个类

调用:

威尼斯人线上娱乐 120/// <summary>  登录
威尼斯人线上娱乐 121        /// </summary>
威尼斯人线上娱乐 122        /// <param name=”url”></param>
威尼斯人线上娱乐 123        /// <param name=”paramList”></param>
威尼斯人线上娱乐 124        /// <returns></returns>
威尼斯人线上娱乐 125        public static string Login(String url, String paramList)
威尼斯人线上娱乐 126        {
威尼斯人线上娱乐 127            HttpWebResponse res = null;
威尼斯人线上娱乐 128            string strResult = “”;
威尼斯人线上娱乐 129            try
威尼斯人线上娱乐 130            {
威尼斯人线上娱乐 131                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
威尼斯人线上娱乐 132                req.Method = “POST”;
威尼斯人线上娱乐 133                req.ContentType = “application/x-www-form-urlencoded”;
威尼斯人线上娱乐 134                req.AllowAutoRedirect = false;
威尼斯人线上娱乐 135                CookieContainer cookieCon = new CookieContainer();
威尼斯人线上娱乐 136                req.CookieContainer = cookieCon;
威尼斯人线上娱乐 137                StringBuilder UrlEncoded = new StringBuilder();
威尼斯人线上娱乐 138                Char[] reserved = { ‘?’, ‘=’, ‘&’ };
威尼斯人线上娱乐 139                byte[] SomeBytes = null;
威尼斯人线上娱乐 140                if (paramList != null)
威尼斯人线上娱乐 141                {
威尼斯人线上娱乐 142                    int i = 0, j;
威尼斯人线上娱乐 143                    while (i < paramList.Length)
威尼斯人线上娱乐 144                    {
威尼斯人线上娱乐 145                        j = paramList.IndexOfAny(reserved, i);
威尼斯人线上娱乐 146                        if (j == -1)
威尼斯人线上娱乐 147                        {
威尼斯人线上娱乐 148                            UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, paramList.Length – i)));
威尼斯人线上娱乐 149                            break;
威尼斯人线上娱乐 150                        }
威尼斯人线上娱乐 151                        UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, j – i)));
威尼斯人线上娱乐 152                        UrlEncoded.Append(paramList.Substring(j, 1));
威尼斯人线上娱乐 153                        i = j + 1;
威尼斯人线上娱乐 154                    }
威尼斯人线上娱乐 155                    SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
威尼斯人线上娱乐 156                    req.ContentLength = SomeBytes.Length;
威尼斯人线上娱乐 157                    Stream newStream = req.GetRequestStream();
威尼斯人线上娱乐 158                    newStream.Write(SomeBytes, 0, SomeBytes.Length);
威尼斯人线上娱乐 159                    newStream.Close();
威尼斯人线上娱乐 160                }
威尼斯人线上娱乐 161                else
威尼斯人线上娱乐 162                {
威尼斯人线上娱乐 163                    req.ContentLength = 0;
威尼斯人线上娱乐 164                }
威尼斯人线上娱乐 165
威尼斯人线上娱乐 166                res = (HttpWebResponse)req.GetResponse();
威尼斯人线上娱乐 167                cookieheader = req.CookieContainer.GetCookieHeader(new Uri(url));
威尼斯人线上娱乐 168效仿登录总计,开发总计。                Stream ReceiveStream = res.GetResponseStream();
威尼斯人线上娱乐 169                Encoding encode = System.Text.Encoding.GetEncoding(“GBK”);
威尼斯人线上娱乐 170                StreamReader sr = new StreamReader(ReceiveStream, encode);
威尼斯人线上娱乐 171                Char[] read = new Char[256];
威尼斯人线上娱乐 172                int count = sr.Read(read, 0, 256);
威尼斯人线上娱乐 173                while (count > 0)
威尼斯人线上娱乐 174                {
威尼斯人线上娱乐 175                    String str = new String(read, 0, count);
威尼斯人线上娱乐 176                    strResult += str;
威尼斯人线上娱乐 177                    count = sr.Read(read, 0, 256);
威尼斯人线上娱乐 178                }
威尼斯人线上娱乐 179            }
威尼斯人线上娱乐 180            catch (Exception e)
威尼斯人线上娱乐 181            {
威尼斯人线上娱乐 182                strResult = e.ToString();
威尼斯人线上娱乐 183            }
威尼斯人线上娱乐 184            finally
威尼斯人线上娱乐 185            {
威尼斯人线上娱乐 186                if (res != null)
威尼斯人线上娱乐 187                {
威尼斯人线上娱乐 188                    res.Close();
威尼斯人线上娱乐 189                }
威尼斯人线上娱乐 190            }
威尼斯人线上娱乐 191            return strResult;
威尼斯人线上娱乐 192        }
威尼斯人线上娱乐 193        /// <summary>  获取页面HTML
威尼斯人线上娱乐 194        /// </summary>
威尼斯人线上娱乐 195        /// <param name=”url”></param>
威尼斯人线上娱乐 196        /// <param name=”paramList”></param>
威尼斯人线上娱乐 197        /// <returns></returns>
威尼斯人线上娱乐 198        public static string getPage(String url, String paramList)
威尼斯人线上娱乐 199        {
威尼斯人线上娱乐 200            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
威尼斯人线上娱乐 201            req.Headers[“If-None-Match”] = “36d0ed736e88c71:d9f”;
威尼斯人线上娱乐 202            req.Referer = “”;
威尼斯人线上娱乐 203            CookieContainer cookieCon = new CookieContainer();
威尼斯人线上娱乐 204            req.CookieContainer = cookieCon;
威尼斯人线上娱乐 205            req.CookieContainer.SetCookies(new Uri(url), cookieheader);
威尼斯人线上娱乐 206            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
威尼斯人线上娱乐 207            StreamReader sr = new StreamReader(res.GetResponseStream(),Encoding.Default);
威尼斯人线上娱乐 208            string strResult = sr.ReadToEnd();
威尼斯人线上娱乐 209            sr.Close();
威尼斯人线上娱乐 210            return strResult;
威尼斯人线上娱乐 211        }

笔者要做的正是 
模拟浏览器的操作,把它转换来大家友好的客户端。所以1旦是浏览器里有的大家都要效仿。接下来判断2维码失效,两秒3次啊,弄三个Timer

/// <summary>
/// HTTP互联网通信类
/// </summary>
public static class HTTP
{

        string postData =
“userName=admin&password=pass&area=2006&Submit=%B5%C7+%C2%BC”;            
        string strLogin, strResult;
        strLogin = Login(“”, postData);

调用:

 

public static CookieContainer cookies = new CookieContainer();
static CookieCollection CookieCollection = new CookieCollection();
static CookieContainer CookieContainer = new CookieContainer();
/// <summary>
/// HTTP请求
/// </summary>
/// <param name=”url”>连接</param>
/// <param name=”enc”>编码</param>
/// <returns></returns>
public static string HttpGet(string url, Encoding enc)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create;
request.Timeout = 10000;//设置10秒超时
request.Proxy = null;
request.Method = “GET”;
request.ContentType = “application/x-www-from-urlencoded”;
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream;
StringBuilder sb = new StringBuilder();
sb.Append(reader.ReadToEnd;
reader.Close();
reader.Dispose();
response.Close();
return sb.ToString();
}
/// <summary>
/// 带referer的http请求连接
/// </summary>
/// <param name=”url”></param>
/// <param name=”referer”></param>
/// <param name=”timeout”></param>
/// <param name=”encode”></param>
/// <param name=”NoProxy”></param>
/// <returns></returns>
public static string Get(string url, string referer =
“”, int
timeout = 100000, Encoding encode = null, bool NoProxy = false)
{
string dat;
HttpWebResponse res = null;
HttpWebRequest req;
try
{
req = (HttpWebRequest)WebRequest.Create;
req.CookieContainer = cookies;
req.AllowAutoRedirect = false;
req.Timeout = timeout;
req.Referer = referer;
if
req.Proxy = null;
req.UserAgent = “Mozilla/5.0 (Windows NT 10.0;%20WOW64; rv:47.0)
Gecko/20100101 Firefox/47.0”;
res = (HttpWebResponse)req.GetResponse();

         strResult = getPage(“”, “”);
//输出
         this.webBrowser1.Document.Write(strResult);

        string postData =
“userName=admin&password=pass&area=2006&Submit=%B5%C7+%C2%BC”;            
        string strLogin, strResult;
        strLogin = Login(“”, postData);

 

cookies.Add(res.Cookies);
}
catch (HttpException)
{
return “”;
}
catch (WebException)
{
return “”;
}
StreamReader reader;

         strResult = getPage(“”, “”);
//输出
         this.webBrowser1.Document.Write(strResult);

smart 类

reader = new StreamReader(res.GetResponseStream(), encode == null ?
Encoding.UTF8 : encode);
dat = reader.ReadToEnd();

#region 第二讲检查2维码状态
private static System.Timers.Timer StatuTimer = new
System.Timers.Timer();
public static void Login()
{
StatuTimer.AutoReset = true;
StatuTimer.Elapsed +=StatuTimer_Elapsed;
StatuTimer.Interval = 2000;
StatuTimer.Start();
}

res.Close();
req.Abort();

public static string Login_err = “其他”;
/// <summary>
/// 检查贰维码状态
/// </summary>
public static void Login_GetStatu()
{
string dat;
dat =
HTTP.Get(string.Format(“”,
ptqrtoken));
string[] temp = dat.Split(‘\”);
switch (temp[1])
{
case (“陆5”): //二维码失效
Login_err = “2维码失效”;
break;
case (“66”): //等待扫描
Login_err = “等待扫描”;
break;
case (“六7”): //等待确认
Login_err = “等待确认”;
break;
case (“0”): //已经确认
Login_err = “已经承认”;
StatuTimer.Stop();
break;

return dat;
}
/// <summary>
/// 带referer data的http post
/// </summary>
/// <param name=”url”></param>
/// <param name=”data”></param>
/// <param name=”Referer”></param>
/// <param name=”timeout”></param>
/// <param name=”encode”></param>
/// <returns></returns>
public static string Post(string url, string data, string Referer =

method= “POST”, int timeout = 100000, Encoding encode = null)
{
string dat = “”;
HttpWebRequest req;
try
{
req = WebRequest.Create as HttpWebRequest;
req.CookieContainer = cookies;
req.ContentType = “application/x-www-form-urlencoded”;
req.Method = method;
req.Proxy = null;
req.Timeout = timeout;
req.UserAgent = “Mozilla/5.0 (Windows NT 10.0;%20WOW64; rv:47.0)
Gecko/20100101 Firefox/47.0”;
req.ProtocolVersion = HttpVersion.Version10;
req.Referer = Referer;

default: break;
}

byte[] mybyte = Encoding.Default.GetBytes;
req.ContentLength = mybyte.Length;

}

Stream stream = req.GetRequestStream();
stream.Write(mybyte, 0, mybyte.Length);

/// <summary>
/// 每两秒检查叁回二维码状态
/// </summary>
private static void StatuTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
Login_GetStatu();
}
#endregion

HttpWebResponse res = req.GetResponse() as HttpWebResponse;

 

cookies.Add(res.Cookies);
stream.Close();

 

StreamReader SR = new StreamReader(res.GetResponseStream(), encode ==
null ? Encoding.UTF8 : encode);
dat = SR.ReadToEnd();
res.Close();
req.Abort();
}
catch (HttpException)
{
return “”;
}
catch (WebException)
{
return “”;
}

HTTP 类

return dat;
}
/// <summary>
/// Hash 转换
/// </summary>
/// <param name=”s”></param>
/// <returns></returns>
public static int Hash33
{
var e = 0;
foreach (var t in s)
e += (e << 5) + t;
return int.MaxValue & e;
}
/// <summary>
/// 获取CookieCollection下 所有cookie
/// </summary>
/// <param name=”cc”></param>
/// <returns></returns>
public static string GetAllCookies(CookieCollection cc)
{
//List<Cookie> lstCookies = new List<Cookie>();
string lstCookies = “”;
ArrayList table = (ArrayList)cc.GetType().InvokeMember(“m_list”,
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.GetField |
System.Reflection.BindingFlags.Instance, null, cc, new object[] { });

 

if (table != null)
{
for (int i = 0; i < table.Count; i++)
{
string[] tacookie = table[i].ToString().Split;
lstCookies = tacookie[1].ToString;
}
}

/// <summary>
/// 带referer的http请求连接
/// </summary>
/// <param name=”url”></param>
/// <param name=”referer”></param>
/// <param name=”timeout”></param>
/// <param name=”encode”></param>
/// <param name=”NoProxy”></param>
/// <returns></returns>
public static string Get(string url, string referer =
“”, int
timeout = 100000, Encoding encode = null, bool NoProxy = false)
{
string dat;
HttpWebResponse res = null;
HttpWebRequest req;
try
{
req = (HttpWebRequest)WebRequest.Create(url);
req.CookieContainer = cookies;
req.AllowAutoRedirect = false;
req.Timeout = timeout;
req.Referer = referer;
if (NoProxy)
req.Proxy = null;
req.UserAgent = “Mozilla/5.0 (Windows NT 10.0;%20WOW64; rv:47.0)
Gecko/20100101 Firefox/47.0”;
res = (HttpWebResponse)req.GetResponse();

return lstCookies;
}
public delegate void Post_Async_Action(string data);
private class Post_Async_Data
{
public HttpWebRequest req;
public Post_Async_Action post_Async_Action;
}
public static void Post_Async(string url, string PostData,
Post_Async_Action action, string Referer =
“”, int
timeout = 100000)
{
HttpWebRequest req = WebRequest.Create as HttpWebRequest;
req.CookieContainer = cookies;
req.ContentType = “application/x-www-form-urlencoded”;
req.Method = “POST”;
req.Referer = Referer;
req.UserAgent = “Mozilla/5.0 (Windows NT 10.0;%20WOW64; rv:47.0)
Gecko/20100101 Firefox/47.0”;
req.Proxy = null;
req.ProtocolVersion = HttpVersion.Version10;
req.ContinueTimeout = timeout;

cookies.Add(res.Cookies);
}
catch (HttpException)
{
return “”;
}
catch (WebException)
{
return “”;
}
StreamReader reader;

ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes;
Stream stream = req.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();

reader = new StreamReader(res.GetResponseStream(), encode == null ?
Encoding.UTF8 : encode);
dat = reader.ReadToEnd();

Post_Async_Data dat = new Post_Async_Data();
dat.req = req;
dat.post_Async_Action = action;
req.BeginGetResponse(new AsyncCallback(Post_Async_ResponesProceed),
dat);
}

res.Close();
req.Abort();

private static void Post_Async_ResponesProceed(IAsyncResult ar)
{
StreamReader reader = null;
Post_Async_Data dat = ar.AsyncState as Post_Async_Data;
HttpWebRequest req = dat.req;
HttpWebResponse res = req.GetResponse() as HttpWebResponse;
reader = new StreamReader(res.GetResponseStream;
string temp = reader.ReadToEnd();
res.Close();
req.Abort();
dat.post_Async_Action;
}
}

return dat;
}

因此总计下来差不七只假设精通一点http协议,基本上网页版的次序,咱们都得以随便的转换到图形桌面版,从而遵照本身本人工作展开开发。

 

附带本人接触过
最多的正是天猫客,天猫Tmall京东店数据,当然那么些都以法定api的。kaola jd
tianmao 等购物网址的分类,商品数量爬取分析。

第贰回发新手教程很多只怕看的不是很明白,可是有源码。能够依据源码的注释举办学习。当中最根本的是json的辨析了。因为本人也是新手,所以广大都以要查一下材料才知晓的。希望这几讲能给一些读书http协议的新手一些启发(小编也是新手,说错勿怪。)

接下去正是做个图形界面包车型大巴smart qq机器人。


相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图