Esempio n. 1
0
        public static string AddItemToXuanpinku(string groupid, System.Collections.ArrayList itemids, ref CookieContainer alimamacc)
        {
            string result    = "";
            string url       = "http://pub.alimama.com/favorites/item/batchAdd.json";
            string tbtoken   = Alimama.GetTbToken(alimamacc);
            string encodeids = "";

            for (int i = 0; i < itemids.Count; i++)
            {
                if (i + 1 != itemids.Count)
                {
                    encodeids += itemids[i] + "%2C";
                }
                else
                {
                    encodeids += itemids[i];
                }
            }

            string poststr = "groupId=" + groupid + "&itemListStr=" + encodeids + "&t=" + HttpHelper1.GetTicks() + "&_tb_token_=" + tbtoken + "&pvid=10_118.145.0.220_431_1496130793991";
            string refer   = "http://pub.alimama.com/promo/search/index.htm?q=1&t=" + HttpHelper1.GetTicks();

            result = HttpHelper1.SendDataByPost(url, poststr, refer, ref alimamacc);
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 阿里妈妈搜索店铺
        /// </summary>
        /// <param name="query"></param>
        /// <param name="pv_id"></param>
        /// <param name="alimamacc"></param>
        /// <returns></returns>
        public static AlimamaSearchShopData GetSearchData(string query, string pv_id, CookieContainer alimamacc)
        {
            AlimamaSearchShopData alimamasearchdata = new AlimamaSearchShopData();
            string tbtoken = Alimama.GetTbToken(alimamacc);
            string url     = "http://pub.alimama.com/shopsearch/shopList.json?spm=a2320.7388781.a214tr8.d006.QkMiw1&q=" + HttpUtility.UrlEncode(query) + "&toPage=1&perPagesize=40&t=" + HttpHelper1.GetTicks() + "&pvid=" + pv_id + "&_tb_token_=" + tbtoken + "&_input_charset=utf-8";
            string result  = HttpHelper1.SendDataByGET(url, ref alimamacc);

            alimamasearchdata = Newtonsoft.Json.JsonConvert.DeserializeObject <AlimamaSearchShopData>(result);
            return(alimamasearchdata);
        }
Esempio n. 3
0
        public static CookieContainer Login(string username, string password)
        {
            string          posturl   = "https://login.taobao.com/member/login.jhtml?redirectURL=http%3A%2F%2Flogin.taobao.com%2Fmember%2Ftaobaoke%2Flogin.htm%3Fis_login%3D1";
            string          poststr   = "TPL_username="******"&TPL_password="******"&ncoSig=&ncoSessionid=&ncoToken=8bb84c14acdeac1ea8a25bd93ff9b3e8141bc70e&slideCodeShow=false&useMobile=false&lang=zh_CN&loginsite=0&newlogin=&TPL_redirect_url=http%3A%2F%2Flogin.taobao.com%2Fmember%2Ftaobaoke%2Flogin.htm%3Fis_login%3D1&from=alimama&fc=default&style=mini&css_style=&keyLogin=false&qrLogin=true&newMini=false&newMini2=true&tid=&loginType=3&minititle=&minipara=&pstrong=&sign=&need_sign=&isIgnore=&full_redirect=true&sub_jump=&popid=&callback=&guf=&not_duplite_str=&need_user_id=&poy=&gvfdcname=&gvfdcre=&from_encoding=&sub=false&TPL_password_2=&loginASR=1&loginASRSuc=0&allp=&oslanguage=&sr=&osVer=&naviVer=&osACN=&osAV=&osPF=&miserHardInfo=&appkey=&bind_login=false&bind_token=&nickLoginLink=&mobileLoginLink=https%3A%2F%2Flogin.taobao.com%2Fmember%2Flogin.jhtml%3Fstyle%3Dmini%26newMini2%3Dtrue%26from%3Dalimama%26redirectURL%3Dhttp%3A%2F%2Flogin.taobao.com%2Fmember%2Ftaobaoke%2Flogin.htm%3Fis_login%3D1%26full_redirect%3Dtrue%26disableQuickLogin%3Dtrue%26useMobile%3Dtrue";
            CookieContainer cc        = new CookieContainer();
            string          refer     = "http://login.taobao.com/member/taobaoke/login.htm/is_login=1";
            string          result    = HttpHelper1.SendDataByPost(posturl, poststr, refer, ref cc);
            string          strurl    = "https://www.alimama.com/membersvc/my.htm?domain=taobao&service=user_on_taobao&sign_account=a49f9f62502fc96517a626ea7e685eb4";
            string          resultstr = HttpHelper1.SendDataByGET(strurl, ref cc);
            bool            isLogin   = Alimama.TestLogin(cc);

            return(cc);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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;
            }
        }