예제 #1
0
        public static string GetCouponInfo(string resulthtml, string itemurl, CookieContainer alimamacc, ref string tbkshortlink)
        {
            string pv_id = "";

            HttpHelper1.GetStringInTwoKeyword(resulthtml, ref pv_id, "pvid\":\"", "\",\"", 0);
            string itemid = "";

            HttpHelper1.GetStringInTwoKeyword(resulthtml, ref itemid, "auctionId\":", ",\"", 0);
            CookieCollection ccl            = alimamacc.GetCookies(new Uri("http://alimama.com"));
            string           tbtoken        = ccl["_tb_token_"].Value;
            DEWeiboAccount   deweiboaccount = WeiboHandler.GetOneAccount();

            //高佣搜索,先查看是否有高佣商品链接
            string url    = "http://pub.alimama.com/common/code/getAuctionCode.json?auctionid=" + itemid + "&adzoneid=" + deweiboaccount.Adzoneid + "&siteid=" + deweiboaccount.Siteid + "&scenes=3&channel=tk_qqhd&t=" + HttpHelper1.GetTicks() + "&_tb_token_=" + tbtoken + "&pvid=" + pv_id;
            string result = HttpHelper1.SendDataByGET(url, ref alimamacc);

            if (result.Contains("参数错误"))
            {
                url    = "http://pub.alimama.com/common/code/getAuctionCode.json?auctionid=" + itemid + "&adzoneid=" + deweiboaccount.Adzoneid + "&siteid=" + deweiboaccount.Siteid + "&scenes=1&t=" + HttpHelper1.GetTicks() + "&_tb_token_=" + tbtoken + "&pvid=" + pv_id + "&yxjh=-1";
                result = HttpHelper1.SendDataByGET(url, ref alimamacc);
            }
            //正常搜索

            string shorturl = "";

            HttpHelper1.GetStringInTwoKeyword(result, ref shorturl, "couponShortLinkUrl\":\"", "\",\"qrCodeUrl", 0);
            HttpHelper1.GetStringInTwoKeyword(result, ref tbkshortlink, "shortLinkUrl\":\"", "\"", 0);

            return(shorturl);
        }
예제 #2
0
        /// <summary>
        /// 获取淘宝客链接
        /// </summary>
        /// <param name="itemurl">淘宝商品URL</param>
        /// <param name="adzonid">推广组ID</param>
        /// <param name="alimamacc">Cookie</param>
        /// <returns></returns>
        public static string GetTbkLink(string itemurl, string siteid, string adzoneid, CookieContainer alimamacc)
        {
            string           tbkLink = "";
            CookieCollection ccl     = alimamacc.GetCookies(new Uri("http://alimama.com"));
            string           tbtoken = ccl["_tb_token_"].Value;
            string           url     = "http://pub.alimama.com/urltrans/urltrans.json?adzoneid=" + adzoneid + "&promotionURL=" + System.Web.HttpUtility.UrlEncode(itemurl);
            TimeSpan         ts      = DateTime.Now - new DateTime(1970, 1, 1);
            string           ticks   = ts.Ticks.ToString().Substring(0, 13);

            url = "http://pub.alimama.com/urltrans/urltrans.json?siteid=" + siteid + "&adzoneid=" + adzoneid + "&promotionURL=" + System.Web.HttpUtility.UrlEncode(itemurl) + "&t=" + ticks + "&_tb_token_=" + tbtoken + "&_input_charset=utf-8";
            string result = HttpHelper1.SendDataByGET(url, ref alimamacc);

            if (result.Contains("链接不支持转化"))
            {
                return("链接不支持转化");
            }
            if (result.Contains("阿里妈妈"))
            {
                return("阿里妈妈登录失效");
            }
            if (result.Contains("亲,访问受限了"))
            {
                Thread.Sleep(1 * 60 * 1000);
                GetTbkLink(itemurl, siteid, adzoneid, alimamacc);

                //访问受限,等待1分钟
            }
            HttpHelper1.GetStringInTwoKeyword(result, ref tbkLink, "shortLinkUrl\":\"", "\"}", 0);

            return(tbkLink);
        }
예제 #3
0
        public static MblogData GetMblogsWithUrl(string url, ref CookieContainer weibocc)
        {
            string ss = "";
            //string html = HttpHelper1.GetHttpsHtml(url, "", ref ss);

            CookieCollection ccl    = weibocc.GetCookies(new Uri("http://weibo.com"));
            CookieCollection newccl = ccl;

            for (int i = 0; i < newccl.Count; i++)
            {
                newccl[i].Domain = "weibo.cn";
            }
            CookieContainer newcc = new CookieContainer();

            weibocc.Add(new Uri("http://weibo.cn"), newccl);

            string html = HttpHelper1.SendDataByGET(url, ref weibocc);

            if (html.Length < 1000)
            {
                for (int i = 0; i < newccl.Count; i++)
                {
                    newccl[i].Domain = "sina.com.cn";
                }
                newcc = new CookieContainer();
                weibocc.Add(new Uri("http://sina.com.cn"), newccl);


                string ssourl1    = "http://login.sina.com.cn/sso/login.php?url=http%3A%2F%2Fm.weibo.cn%2F&_rand=" + HttpHelper1.GetTicks() + ".3493&gateway=1&service=sinawap&entry=sinawap&useticket=1&returntype=META&sudaref=&_client_version=0.6.23";
                string ssoresult1 = HttpHelper1.SendDataByGET(ssourl1, ref weibocc);
                string ssourl2    = "";
                HttpHelper1.GetStringInTwoKeyword(ssoresult1, ref ssourl2, "arrURL\":[\"", "\"]", 0);
                ssourl2 = ssourl2.Replace(@"\/", "/");
                ssourl2 = ssourl2 + "&callback=sinaSSOController.doCrossDomainCallBack&scriptId=ssoscript0&client=ssologin.js(v1.4.19)&_=" + HttpHelper1.GetTicks();
                string ssoresult2 = HttpHelper1.SendDataByGET(ssourl2, ref weibocc);

                ccl    = weibocc.GetCookies(new Uri("http://sina.com.cn"));
                newccl = ccl;
                for (int i = 0; i < newccl.Count; i++)
                {
                    newccl[i].Domain = "weibo.cn";
                }
                newcc = new CookieContainer();
                weibocc.Add(new Uri("http://weibo.cn"), newccl);
                html = HttpHelper1.SendDataByGET(url, ref weibocc);
            }
            for (int i = 0; i < newccl.Count; i++)
            {
                newccl[i].Domain = "weibo.com";
            }
            weibocc.Add(newccl);
            if (html.Contains(""))
            {
                html = html.Replace("page\":null", "page\":1");
            }
            MblogData mbloglist = Newtonsoft.Json.JsonConvert.DeserializeObject <MblogData>(html);

            return(mbloglist);
        }
예제 #4
0
        public static SignalWeiboData GetSignalWeibo(string weibourl)
        {
            SignalWeiboData weibo     = new SignalWeiboData();
            CookieContainer weibocc   = new CookieContainer();
            string          result    = HttpHelper1.SendDataByGET(weibourl, ref weibocc);
            string          weibojson = "";

            HttpHelper1.GetStringInTwoKeyword(result, ref weibojson, "$render_data = [", "][0] || {};", 0);
            weibo = Newtonsoft.Json.JsonConvert.DeserializeObject <SignalWeiboData>(weibojson);
            return(weibo);
        }
예제 #5
0
        public static string GetWeiboShorturl(string url)
        {
            string          shorturl   = "";
            string          encodeurl  = HttpUtility.UrlEncode(url);
            string          poststring = "url=" + encodeurl + "&d=1";
            string          geturl     = "http://api.t.sina.com.cn/short_url/shorten.json?source=2465536411&url_long=" + encodeurl;
            CookieContainer cc         = new CookieContainer();
            string          json       = HttpHelper1.SendDataByGET(geturl, ref cc);

            HttpHelper1.GetStringInTwoKeyword(json, ref shorturl, "url_short\":\"", "\"", 0);
            return(shorturl);
        }
예제 #6
0
        /// <summary>
        /// 创建选品库
        /// </summary>
        /// <param name="title">选品库名称</param>
        /// <param name="alimamacc"></param>
        /// <returns>选品库ID</returns>
        public static string CreatXuanpinku(string title, ref CookieContainer alimamacc)
        {
            string result      = "";
            string groupId     = "";
            string url         = "http://pub.alimama.com/favorites/group/save.json";
            string tbtoken     = Alimama.GetTbToken(alimamacc);
            string encodetitle = HttpUtility.UrlEncode(title);
            string poststr     = "groupTitle=" + encodetitle + "&groupType=1&t=" + HttpHelper1.GetTicks() + "&_tb_token_=" + tbtoken + "&pvid=";
            string refer       = "http://pub.alimama.com/promo/search/index.htm?q=1&t=" + HttpHelper1.GetTicks();

            result = HttpHelper1.SendDataByPost(url, poststr, refer, ref alimamacc);
            HttpHelper1.GetStringInTwoKeyword(result, ref groupId, "{\"data\":{\"data\":", "},\"", 0);
            return(groupId);
        }
예제 #7
0
        public static string SendWeiboFromM(string weibotext, string picids, string refer, DEWeiboAccount deweiboaccount, CookieContainer weibocc)
        {
            string url = "https://m.weibo.cn/mblogDeal/addAMblog";

            picids = picids.Replace("%20", "%2C");
            refer  = "https://m.weibo.cn/mblog";


            CookieCollection ccl    = weibocc.GetCookies(new Uri("http://weibo.com"));
            CookieCollection newccl = ccl;

            for (int i = 0; i < newccl.Count; i++)
            {
                newccl[i].Domain = "sina.com.cn";
            }
            CookieContainer newcc = new CookieContainer();

            weibocc.Add(new Uri("http://sina.com.cn"), newccl);


            string ssourl1    = "http://login.sina.com.cn/sso/login.php?url=http%3A%2F%2Fm.weibo.cn%2F&_rand=" + HttpHelper1.GetTicks() + ".3493&gateway=1&service=sinawap&entry=sinawap&useticket=1&returntype=META&sudaref=&_client_version=0.6.23";
            string ssoresult1 = HttpHelper1.SendDataByGET(ssourl1, ref weibocc);
            string ssourl2    = "";

            HttpHelper1.GetStringInTwoKeyword(ssoresult1, ref ssourl2, "arrURL\":[\"", "\"]", 0);
            ssourl2 = ssourl2.Replace(@"\/", "/");
            ssourl2 = ssourl2 + "&callback=sinaSSOController.doCrossDomainCallBack&scriptId=ssoscript0&client=ssologin.js(v1.4.19)&_=" + HttpHelper1.GetTicks();
            string ssoresult2 = HttpHelper1.SendDataByGET(ssourl2, ref weibocc);

            ccl    = weibocc.GetCookies(new Uri("http://sina.com.cn"));
            newccl = ccl;
            for (int i = 0; i < newccl.Count; i++)
            {
                newccl[i].Domain = "weibo.cn";
            }
            newcc = new CookieContainer();
            weibocc.Add(new Uri("http://weibo.cn"), newccl);

            string poststr = "content=" + HttpUtility.UrlEncode(weibotext) + "&picId=" + picids + "&annotations=&st=" + deweiboaccount.St;
            string result  = HttpHelper1.SendDataByPost(url, poststr, refer, ref weibocc);

            for (int i = 0; i < newccl.Count; i++)
            {
                newccl[i].Domain = "weibo.com";
            }
            weibocc.Add(newccl);
            return(result);
        }
예제 #8
0
        /// <summary>
        /// 提交验证码验证
        /// </summary>
        /// <param name="vcode">验证码</param>
        /// <param name="refer"></param>
        /// <param name="weibocc"></param>
        /// <returns></returns>
        public static string GetVcodeRetcode(string vcode, string refer, CookieContainer weibocc)
        {
            string retcode     = "";
            string yanzhengurl = "http://weibo.com/aj/pincode/verified?ajwvr=6";

            string vcode_urlencode = HttpUtility.UrlEncode(vcode);
            string yanzhengpost    = "secode=" + vcode_urlencode + "&type=rule";
            string yanzhengresult  = HttpHelper1.SendDataByPost(yanzhengurl, yanzhengpost, refer, ref weibocc);

            if (yanzhengresult.Contains("{\"code\":\"100000\""))
            {
                //验证通过
                HttpHelper1.GetStringInTwoKeyword(yanzhengresult, ref retcode, "retcode\":\"", "\"}}", 0);
                return(retcode);
            }
            return(retcode);
        }
예제 #9
0
        public static bool TestLogin(string username, ref CookieContainer cc, ref string uid)
        {
            cc = InitWeiboCookie(username);
            if (cc == null)
            {
                return(false);
            }
            string url       = "http://www.weibo.com/";
            string strresult = HttpHelper1.SendDataByGET(url, ref cc);

            if (!strresult.Contains("我的首页"))
            {
                return(false);
            }
            HttpHelper1.GetStringInTwoKeyword(strresult, ref uid, "$CONFIG['uid']='", "';", 0);
            return(true);
        }
예제 #10
0
        public static string GetTbkShortUrl(string tbkurl)
        {
            //tbkurl= "https://uland.taobao.com/coupon/edetail?activityId=cca299fffaee4c45bbfa541ac208dd16&pid=mm_122033678_24252915_81212616&itemId=547482547612&src=fklm_hltk&dx=1";
            string url = "http://gw.api.taobao.com/router/rest";

            ITopClient client = new DefaultTopClient(url, Alimama.appkey, Alimama.secret);

            TbkSpreadGetRequest req = new TbkSpreadGetRequest();
            List <TbkSpreadGetRequest.TbkSpreadRequestDomain> list2 = new List <TbkSpreadGetRequest.TbkSpreadRequestDomain>();

            TbkSpreadGetRequest.TbkSpreadRequestDomain obj3 = new TbkSpreadGetRequest.TbkSpreadRequestDomain();
            list2.Add(obj3);
            obj3.Url      = tbkurl;
            req.Requests_ = list2;
            TbkSpreadGetResponse rsp1 = client.Execute(req);
            string tbkshorturl        = "";

            HttpHelper1.GetStringInTwoKeyword(rsp1.Body, ref tbkshorturl, "<content>", "</content>", 0);
            return(tbkshorturl);
        }
예제 #11
0
        public static string GetTbkTaokouling(string tburl)
        {
            //tbkurl= "https://uland.taobao.com/coupon/edetail?activityId=cca299fffaee4c45bbfa541ac208dd16&pid=mm_122033678_24252915_81212616&itemId=547482547612&src=fklm_hltk&dx=1";
            string url = "http://gw.api.taobao.com/router/rest";

            ITopClient client = new DefaultTopClient(url, appkey, secret);
            WirelessShareTpwdCreateRequest req = new WirelessShareTpwdCreateRequest();

            WirelessShareTpwdCreateRequest.GenPwdIsvParamDtoDomain obj1 = new WirelessShareTpwdCreateRequest.GenPwdIsvParamDtoDomain();
            obj1.Ext       = "{\"xx\":\"xx\"}";
            obj1.Logo      = "http://m.taobao.com/xxx.jpg";
            obj1.Url       = "http://m.taobao.com";
            obj1.Text      = "超值活动,惊喜活动多多";
            obj1.UserId    = 24234234234L;
            req.TpwdParam_ = obj1;
            WirelessShareTpwdCreateResponse rsp = client.Execute(req);

            string tbkshorturl = "";

            HttpHelper1.GetStringInTwoKeyword(rsp.Body, ref tbkshorturl, "<content>", "</content>", 0);
            return(rsp.Body);
        }
예제 #12
0
        public static CampainsData GetCampainByTBItemID(string itemid, string tbtoken, string pv_id, ref CookieContainer alimamacc, ref string keeperid)
        {
            string url        = "http://pub.alimama.com/pubauc/getCommonCampaignByItemId.json?itemId=" + itemid + "&t=" + HttpHelper1.GetTicks() + "&_tb_token_=" + tbtoken + "&pvid=" + pv_id;
            string resulthtml = HttpHelper1.SendDataByGET(url, ref alimamacc);

            while (resulthtml.Contains("查询商品佣金出错"))
            {
                Thread.Sleep(30 * 1000);
                resulthtml = HttpHelper1.SendDataByGET(url, ref alimamacc);
            }
            if (resulthtml.Contains("为空"))
            {
                return(null);
            }
            else if (resulthtml.Contains("阿里妈妈"))//返回阿里妈妈首页,登录失效
            {
                alimamacc  = Alimama.Login();
                resulthtml = HttpHelper1.SendDataByGET(url, ref alimamacc);
            }
            HttpHelper1.GetStringInTwoKeyword(resulthtml, ref keeperid, "ShopKeeperID\":", ",\"Properties", 0);
            CampainsData campains = Newtonsoft.Json.JsonConvert.DeserializeObject <CampainsData>(resulthtml);

            return(campains);
        }
예제 #13
0
        public static string GetSTFromM(CookieContainer cc)
        {
            string url = "http://m.weibo.cn";

            CookieCollection ccl    = cc.GetCookies(new Uri("http://weibo.cn"));
            CookieCollection newccl = ccl;

            for (int i = 0; i < newccl.Count; i++)
            {
                newccl[i].Domain = "weibo.cn";
            }
            CookieContainer newcc = new CookieContainer();

            newcc.Add(new Uri("http://weibo.cn"), newccl);
            string result = HttpHelper1.SendDataByGET(url, ref newcc);
            string st     = "";

            HttpHelper1.GetStringInTwoKeyword(result, ref st, "st\":\"", "\"", 0);
            for (int i = 0; i < newccl.Count; i++)
            {
                newccl[i].Domain = "weibo.com";
            }
            return(st);
        }
예제 #14
0
        /// <summary>
        /// 自动申请定向计划
        /// </summary>
        /// <param name="campaignid">定向计划ID</param>
        /// <returns>true:申请成功,false:没有定向计划</returns>
        public static bool ApplyCampaign(string resulthtml, string itemurl, ref CookieContainer alimamacc, ref double maxRate)
        {
            try
            {
                string campaignstrs = "";
                HttpHelper1.GetStringInTwoKeyword(resulthtml, ref campaignstrs, "tkSpecialCampaignIdRateMap\":", ",\"eventCreatorId", 0);
                if (campaignstrs.StartsWith("null"))
                {
                    return(false);                                //如果没有定向计划,退出
                }
                string pv_id = "";
                HttpHelper1.GetStringInTwoKeyword(resulthtml, ref pv_id, "pvid\":\"", "\",\"docsfound", 0);
                string itemid = "";
                HttpHelper1.GetStringInTwoKeyword(resulthtml, ref itemid, "auctionId\":", ",\"", 0);
                string keeperid   = "";
                string maxratestr = "";
                HttpHelper1.GetStringInTwoKeyword(resulthtml, ref maxratestr, "tkRate\":", "\"", 0);
                maxratestr = maxratestr.Replace(",", "");

                CookieCollection ccl          = alimamacc.GetCookies(new Uri("http://alimama.com"));
                string           tbtoken      = ccl["_tb_token_"].Value;
                string           refer        = "http://pub.alimama.com/promo/search/index.htm?queryType=2&q=" + HttpUtility.UrlEncode(itemurl);
                CampainsData     campainsdata = Alimama.GetCampainByTBItemID(itemid, tbtoken, pv_id, ref alimamacc, ref keeperid);
                if (campainsdata == null)
                {
                    return(false);
                }
                //if (IsCampaignExits(campainsdata, alimamacc,ref keeperid)) return false;//如果申请过定向计划,退出
                double maxCommission = 0;
                maxCommission = Convert.ToDouble(maxratestr);
                double maxManualCommission = 0;


                CampainsData.Datum maxCampaign       = new CampainsData.Datum();
                CampainsData.Datum maxManualCampaign = new CampainsData.Datum();
                //挑选出自动审核计划中,佣金最高的一个
                foreach (CampainsData.Datum campain in campainsdata.data)
                {
                    if (campain.AvgCommission == "-")
                    {
                        continue;
                    }
                    double commission = Convert.ToDouble(campain.AvgCommission.Replace(" %", ""));
                    if (campain.manualAudit == 1)//如果需要人工审核
                    {
                        if (commission > maxManualCommission)
                        {
                            maxManualCommission = commission;
                            maxManualCampaign   = campain;
                        }
                    }
                    else
                    {
                        if (commission > maxCommission)
                        {
                            maxCommission = commission;
                            maxCampaign   = campain;
                        }
                    }
                }
                if (!maxCampaign.Exist && maxCampaign.CampaignID != 0)
                {
                    ApplyCampaign(maxCampaign.CampaignID.ToString(), keeperid, pv_id, refer, alimamacc);//自动审核最高分成比例的计划一定要申请
                }
                maxRate = maxCommission;
                if (maxCommission < maxManualCommission)
                {
                    if (!maxManualCampaign.Exist)
                    {
                        ApplyCampaign(maxManualCampaign.CampaignID.ToString(), keeperid, pv_id, refer, alimamacc);//如果人工审核的计划分成比例要更高,则再申请人工审核计划
                        if (maxManualCampaign.CampaignName.Contains("QQ"))
                        {
                            File.AppendAllText("taobaoke定向计划.txt", "分成比例:" + maxManualCampaign.AvgCommission + " 计划名称:" + maxManualCampaign.CampaignName + "\r\n");
                        }
                    }
                    else
                    {
                        //如果人工审核计划已经通过审核
                        maxRate = maxManualCommission;
                    }
                }


                //string[] campains = campaignstrs.Split(',');
                //foreach (string campain in campains)
                //{
                //    string[] campainpro = campain.Split(':');
                //    string campaignid = campainpro[0].Replace("{","").Replace("\"","");
                //    string campaignbili = campainpro[1].Replace("\"","").Replace("}", "");
                //    bool isSuc = ApplyCampaign(campaignid, keeperid,pv_id,refer, alimamacc);
                //}
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #15
0
        /// <summary>
        /// 微博登录
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static CookieContainer Login(string username, string password)
        {
            var             preData = WeiboHandler.PreLogin(username);
            CookieContainer weibocc = new CookieContainer();

            if (preData != null)
            {
                string code = "";
                var    img  = WeiboHandler.GetLoginCodePic(preData.pcid);
                while (code == "" || code == "IERROR" || code == "ERROR")
                {
                    code = Dama2.GetVcode(img);
                }
                //string code = null;
                //var img = WeiboHandler.GetLoginCodePic(preData.pcid);
                var loginData = WeiboHandler.Login(preData, username, password, code);
                weibocc = WeiboHandler.InitWeiboCookie(username, loginData.cookies);
                string testloginresult = "";
                bool   isLogin         = WeiboHandler.TestLogin(weibocc, ref testloginresult);

                if (isLogin)
                {
                    CookieCollection ccl    = weibocc.GetCookies(new Uri("http://weibo.com"));
                    CookieCollection newccl = ccl;
                    for (int i = 0; i < newccl.Count; i++)
                    {
                        newccl[i].Domain = "sina.com.cn";
                    }
                    CookieContainer newcc = new CookieContainer();
                    weibocc.Add(new Uri("http://sina.com.cn"), newccl);


                    string ssourl1    = "http://login.sina.com.cn/sso/login.php?url=http%3A%2F%2Fm.weibo.cn%2F&_rand=" + HttpHelper1.GetTicks() + ".3493&gateway=1&service=sinawap&entry=sinawap&useticket=1&returntype=META&sudaref=&_client_version=0.6.23";
                    string ssoresult1 = HttpHelper1.SendDataByGET(ssourl1, ref weibocc);
                    string ssourl2    = "";
                    HttpHelper1.GetStringInTwoKeyword(ssoresult1, ref ssourl2, "arrURL\":[\"", "\"]", 0);
                    ssourl2 = ssourl2.Replace(@"\/", "/");
                    ssourl2 = ssourl2 + "&callback=sinaSSOController.doCrossDomainCallBack&scriptId=ssoscript0&client=ssologin.js(v1.4.19)&_=" + HttpHelper1.GetTicks();
                    string ssoresult2 = HttpHelper1.SendDataByGET(ssourl2, ref weibocc);

                    ccl    = weibocc.GetCookies(new Uri("http://sina.com.cn"));
                    newccl = ccl;
                    for (int i = 0; i < newccl.Count; i++)
                    {
                        newccl[i].Domain = "weibo.cn";
                    }
                    newcc = new CookieContainer();
                    weibocc.Add(new Uri("http://weibo.cn"), newccl);

                    //登录成功保存Cookie
                    File.AppendAllText("weibocookie/" + username + ".txt", loginData.cookies);
                    return(weibocc);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }