예제 #1
0
파일: Crawler.cs 프로젝트: kaizhiyu/Jvedio
 protected override void InitHeaders()
 {
     headers = new CrawlerHeader()
     {
         Cookies = JvedioServers.Jav321.Cookie
     };
 }
예제 #2
0
파일: Crawler.cs 프로젝트: kaizhiyu/Jvedio
 protected override void InitHeaders()
 {
     headers = new CrawlerHeader()
     {
         Cookies = VedioType == VedioType.欧美?JvedioServers.BusEurope.Cookie: JvedioServers.Bus.Cookie
     };
 }
예제 #3
0
        }                               //必须给出演员名字

        public ActorCrawler(string name)
        {
            Name       = name;
            Url        = "";
            headers    = new CrawlerHeader();
            httpResult = null;
        }
예제 #4
0
파일: Crawler.cs 프로젝트: lq-wq/Jvedio
 protected override void InitHeaders()
 {
     headers = new CrawlerHeader()
     {
         Cookies = AllCookies.MOO
     };
 }
예제 #5
0
파일: Crawler.cs 프로젝트: lq-wq/Jvedio
        protected override void InitHeaders()
        {
            Uri    uri    = new Uri(Url);
            string cookie = "";

            if (UrlCookies.ContainsKey(uri.Host))
            {
                cookie = UrlCookies[uri.Host];
            }
            headers = new CrawlerHeader()
            {
                Cookies = cookie
            };
        }
예제 #6
0
파일: Crawler.cs 프로젝트: kaizhiyu/Jvedio
        protected void InitHeaders(string postdata)
        {
            //sn=pppd-093
            if (!Url.IsProperUrl())
            {
                return;
            }
            Uri uri = new Uri(Url);

            headers = new CrawlerHeader()
            {
                ContentLength = postdata.Length + 3,
                Origin        = uri.Scheme + "://" + uri.Host,
                ContentType   = "application/x-www-form-urlencoded",
                Referer       = uri.Scheme + "://" + uri.Host,
                Method        = "POST",
                Cookies       = JvedioServers.Jav321.Cookie
            };
        }
예제 #7
0
파일: Crawler.cs 프로젝트: lq-wq/Jvedio
        protected void InitHeaders(string postdata)
        {
            //sn=pppd-093
            if (!Url.IsProperUrl())
            {
                return;
            }
            Uri    uri    = new Uri(Url);
            string cookie = "";

            if (UrlCookies.ContainsKey(uri.Host))
            {
                cookie = UrlCookies[uri.Host];
            }
            headers = new CrawlerHeader()
            {
                ContentLength = postdata.Length + 3,
                Origin        = uri.Scheme + "://" + uri.Host,
                ContentType   = "application/x-www-form-urlencoded",
                Referer       = uri.Scheme + "://" + uri.Host,
                Method        = "POST",
                Cookies       = cookie
            };
        }
예제 #8
0
        /// <summary>
        /// Http 请求
        /// </summary>
        /// <param name="Url"></param>
        /// <param name="headers"></param>
        /// <param name="Mode"></param>
        /// <param name="Proxy"></param>
        /// <param name="allowRedirect"></param>
        /// <param name="poststring"></param>
        /// <returns></returns>
        public static async Task <HttpResult> Http(string Url, CrawlerHeader headers = null, HttpMode Mode = HttpMode.Normal, WebProxy Proxy = null, bool allowRedirect = true, string postString = "")
        {
            if (!Url.IsProperUrl())
            {
                return(null);
            }
            if (headers == null)
            {
                headers = new CrawlerHeader();
            }
            int        trynum     = 0;
            HttpResult httpResult = null;

            try
            {
                while (trynum < ATTEMPTNUM && httpResult == null)
                {
                    httpResult = await Task.Run(() =>
                    {
                        HttpWebRequest Request;
                        HttpWebResponse Response = default;
                        try
                        {
                            Request = (HttpWebRequest)HttpWebRequest.Create(Url);
                        }
                        catch (Exception ex)
                        {
                            Logger.LogE(ex);
                            return(null);
                        }
                        Uri uri                   = new Uri(Url);
                        Request.Host              = headers.Host == "" ? uri.Host : headers.Host;
                        Request.Accept            = headers.Accept;
                        Request.Timeout           = HTTPTIMEOUT;
                        Request.Method            = headers.Method;
                        Request.KeepAlive         = true;
                        Request.AllowAutoRedirect = allowRedirect;
                        Request.Referer           = uri.Scheme + "://" + uri.Host + "/";
                        Request.UserAgent         = headers.UserAgent;
                        Request.Headers.Add("Accept-Language", headers.AcceptLanguage);
                        Request.Headers.Add("Upgrade-Insecure-Requests", headers.UpgradeInsecureRequests);
                        Request.Headers.Add("Sec-Fetch-Site", headers.SecFetchSite);
                        Request.Headers.Add("Sec-Fetch-Mode", headers.SecFetchMode);
                        Request.Headers.Add("Sec-Fetch-User", headers.SecFetchUser);
                        Request.Headers.Add("Sec-Fetch-Dest", headers.SecFetchDest);
                        Request.ReadWriteTimeout = READWRITETIMEOUT;
                        if (headers.Cookies != "")
                        {
                            Request.Headers.Add("Cookie", headers.Cookies);
                        }
                        if (Mode == HttpMode.RedirectGet)
                        {
                            Request.AllowAutoRedirect = false;
                        }
                        if (Proxy != null)
                        {
                            Request.Proxy = Proxy;
                        }

                        try
                        {
                            if (headers.Method == "POST")
                            {
                                Request.Method        = "POST";
                                Request.ContentType   = headers.ContentType;
                                Request.ContentLength = headers.ContentLength;
                                Request.Headers.Add("Origin", headers.Origin);
                                byte[] bs = Encoding.UTF8.GetBytes(postString);
                                using (Stream reqStream = Request.GetRequestStream())
                                {
                                    reqStream.Write(bs, 0, bs.Length);
                                }
                            }
                            Response   = (HttpWebResponse)Request.GetResponse();
                            httpResult = GetHttpResult(Response, Mode);
                            Logger.LogN($" {Jvedio.Language.Resources.Url}:{Url} => {httpResult.StatusCode}");
                        }
                        catch (WebException e)
                        {
                            Logger.LogN($" {Jvedio.Language.Resources.Url}:{Url}, {Jvedio.Language.Resources.Reason}:{e.Message}");
                            if (e.Status == WebExceptionStatus.Timeout)
                            {
                                trynum++;
                            }
                            else
                            {
                                trynum = 2;
                            }
                        }
                        catch (Exception e)
                        {
                            Logger.LogN($" {Jvedio.Language.Resources.Url}:{Url}, {Jvedio.Language.Resources.Reason}:{e.Message}");
                            trynum = 2;
                        }
                        finally
                        {
                            if (Response != null)
                            {
                                Response.Close();
                            }
                        }
                        return(httpResult);
                    }).TimeoutAfter(TimeSpan.FromSeconds(HTTPTIMEOUT));
                }
            }
            catch (TimeoutException ex)
            {
                //任务超时了
                Console.WriteLine(ex.Message);
                Logger.LogN(ex.Message);
            }
            return(httpResult);
        }