コード例 #1
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);
        }
コード例 #2
0
ファイル: WeiboHandler.cs プロジェクト: yankaics/weibo-2
        /// <summary>
        /// 发布单条微博
        /// </summary>
        /// <param name="weibotext">微博正文</param>
        /// <param name="picids">图片ID,空格连接</param>
        /// <param name="refer">来源地址</param>
        /// <param name="weibocc">Cookie</param>
        /// <returns></returns>
        public static string SendWeibo(string weibotext, string picids, string refer, CookieContainer weibocc)
        {
            string ticks = HttpHelper1.GetTicks();

            //PC端发布微博
            string posturl         = "http://www.weibo.com/aj/mblog/add?ajwvr=6&__rnd=" + ticks;
            string encodeweibotext = System.Web.HttpUtility.UrlEncode(weibotext);

            encodeweibotext = encodeweibotext.Replace("%250A", "%0A");
            string poststr = "location=v6_content_home&text=" + encodeweibotext + "&appkey=&style_type=1&pic_id=" + picids + "&pdetail=&gif_ids=&rank=0&rankid=&module=stissue&pub_source=main_&pub_type=dialog&_t=0";

            poststr = poststr.Replace("+", "%20");

            //移动端发布微博

            //string posturl = "http://m.weibo.cn/mblogDeal/addAMblog";
            //string poststr = "content=" + System.Web.HttpUtility.UrlEncode(weibotext) + "&picId="+picids+"&annotations=&st=12283f";

            string result = HttpHelper1.SendDataByPost(posturl, poststr, refer, ref weibocc);

            //判断是否发布成功
            //{"code":"100000"
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// 获取店铺热销单品数据
        /// </summary>
        /// <param name="oriMemberId"></param>
        /// <param name="pv_id"></param>
        /// <param name="alimamacc"></param>
        /// <returns></returns>
        public static AlimamaShopHotData GetShopHotItem(string oriMemberId, string pv_id, CookieContainer alimamacc)
        {
            AlimamaShopHotData alimamashophot = new AlimamaShopHotData();
            string             url            = "http://pub.alimama.com/shopdetail/hotProducts.json?sortField=_totalnum&oriMemberId=" + oriMemberId + "&t=" + HttpHelper1.GetTicks() + "&pvid=" + pv_id + "&_tb_token_=" + GetTbToken(alimamacc) + "&_input_charset=utf-8";
            string             result         = HttpHelper1.SendDataByGET(url, ref alimamacc);

            alimamashophot = Newtonsoft.Json.JsonConvert.DeserializeObject <AlimamaShopHotData>(result);
            return(alimamashophot);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
        public static bool ApplyCampaign(string campaignid, string keeperid, string pv_id, string refer, CookieContainer alimamacc)
        {
            //alimama_searchdata.Data.PageList[0].TkSpecialCampaignIdRateMap
            string           url     = "http://pub.alimama.com/pubauc/applyForCommonCampaign.json";
            CookieCollection ccl     = alimamacc.GetCookies(new Uri("http://alimama.com"));
            string           tbtoken = ccl["_tb_token_"].Value;
            string           poststr = "campId=" + campaignid + "&keeperid=" + keeperid + "&applyreason=%e5%be%ae%e5%8d%9a%e5%a4%a7%e5%8f%b7%e5%af%bc%e8%b4%ad%ef%bc%8cQQ%ef%bc%9a1145837517&t=" + HttpHelper1.GetTicks() + "&_tb_token_=" + tbtoken + "&pvid=" + pv_id;

            string resulthtml = HttpHelper1.SendDataByPost(url, poststr, refer, ref alimamacc);

            return(true);
        }
コード例 #8
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);
        }
コード例 #9
0
        /// <summary>
        /// 获取阿里妈妈搜索商品url内容
        /// </summary>
        /// <param name="itemurl"></param>
        /// <param name="alimamacc"></param>
        /// <returns></returns>
        public static string SearchItem(string itemurl, CookieContainer alimamacc)
        {
            AlimamaSearchData alimama_searchdata = new AlimamaSearchData();
            CookieCollection  ccl = alimamacc.GetCookies(new Uri("http://alimama.com"));

            if (ccl["_tb_token_"] == null)
            {
                return("阿里妈妈未登录");
            }
            string tbtoken   = ccl["_tb_token_"].Value;
            string searchurl = "http://pub.alimama.com/items/search.json?queryType=2&q=" + HttpUtility.UrlEncode(itemurl) + "&auctionTag=&perPageSize=40&shopTag=&t=" + HttpHelper1.GetTicks() + "&_tb_token_=" + tbtoken + "&pvid=10_118.145.0.50_464_1484650244904&yxjh=-1";


            string refer      = "http://pub.alimama.com/promo/search/index.htm?queryType=2&q=" + HttpUtility.UrlEncode(itemurl);
            string resulthtml = HttpHelper1.SendDataByGET(searchurl, refer, ref alimamacc);

            //alimama_searchdata = Newtonsoft.Json.JsonConvert.DeserializeObject<AlimamaSearchData>(resulthtml);
            //string campaignstr = "";

            //HttpHelper1.GetStringInTwoKeyword(resulthtml, ref campaignstr, "", "", 0);

            return(resulthtml);
        }
コード例 #10
0
ファイル: WeiboHandler.cs プロジェクト: yankaics/weibo-2
        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);
        }
コード例 #11
0
ファイル: WeiboHandler.cs プロジェクト: yankaics/weibo-2
        public static string Comment(string mid, string ouid, string commentstr, string refer, CookieContainer weibocc, WebProxy proxy)
        {
            string commenturl = "http://weibo.com/aj/v6/comment/add?ajwvr=6&__rnd=" + HttpHelper1.GetTicks();

            commentstr = System.Web.HttpUtility.UrlEncode(commentstr.Trim());
            commentstr = commentstr.Trim().Replace("+", "%20");

            string commentpoststr = "act=post&mid=" + mid + "&uid=" + ouid + "&forward=0&isroot=0&content=" + commentstr + "&location=&module=scommlist&group_source=&pdetail=&_t=0";
            string commentresult  = HttpHelper1.SendDataByPost(commenturl, commentpoststr, refer, ref weibocc, proxy);

            if (commentresult.Contains("{\"code\":\"100001\""))
            {
                //Thread.Sleep(10 * 60 * 1000);//如果第一次评论就提示发布相同内容,则将线程停顿10分钟
                return(commentresult);//如果第一次评论就报错,一般认为是mid为空,直接返回不处理
            }

            if (commentresult.Contains("{\"code\":\"100027\""))
            {
                //需要输入验证码
                string retcode = "";
                string vcode   = "";

                while (retcode == "")
                {
                    while (vcode == "" || vcode == "IERROR" || vcode == "ERROR")
                    {
                        vcode = HttpHelper1.AutoGetVcode(weibocc);
                    }
                    retcode = WeiboHandler.GetVcodeRetcode(vcode, refer, weibocc);
                    if (retcode == "")
                    {
                        vcode = "";
                    }
                }//拿到验证码,并验证通过,通不过死循环

                commentpoststr = commentpoststr + "&retcode=" + retcode;
                commentresult  = HttpHelper1.SendDataByPost(commenturl, commentpoststr, refer, ref weibocc, proxy);//再次发送评论
            }
            return(commentresult);
        }
コード例 #12
0
ファイル: WeiboHandler.cs プロジェクト: yankaics/weibo-2
        /// <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);
            }
        }
コード例 #13
0
ファイル: WeiboHandler.cs プロジェクト: yankaics/weibo-2
        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);
        }