/// <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); }
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); }
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); }
public static string GetDailiIP() { string url = "http://dev.kuaidaili.com/api/getproxy/?orderid=988306037973723&num=1&area=北京&b_pcchrome=1&b_pcie=1&b_pcff=1&protocol=1&method=2&an_an=1&an_ha=1&sp1=1&sep=1"; CookieContainer cc = new CookieContainer(); string result = HttpHelper1.SendDataByGET(url, ref cc); return(result); }
/// <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); }
/// <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); }
public static bool TestLogin(CookieContainer cc) { string url = "http://www.weibo.com/"; string strresult = HttpHelper1.SendDataByGET(url, ref cc); if (!strresult.Contains("我的首页")) { return(false); } return(true); }
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); }
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); }
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=¬_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); }
public static WeiboComment GetComment(string mid, CookieContainer cc) { try { string commenturl = "http://weibo.com/aj/v6/comment/small?ajwvr=6&act=list&mid=" + mid + "&uid="; string result = HttpHelper1.SendDataByGET(commenturl, ref cc); WeiboComment comment = Newtonsoft.Json.JsonConvert.DeserializeObject <WeiboComment>(result); return(comment); } catch (Exception ex) { return(null); } }
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); }
public static bool TestLogin(string username, ref CookieContainer cc) { 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); } return(true); }
public static bool TestLogin(CookieContainer cc) { bool isLogin = false; //验证登陆 string m_url = "https://www.alimama.com/getLogInfo.htm?callback=__jp0";//地址获取淘宝联盟选品库列表 string jsonlist = HttpHelper1.SendDataByGET(m_url, "https://www.alimama.com/index.htm", ref cc); if (jsonlist.Contains("success\":true"))//未登陆则打开登陆接口 { isLogin = true; } else { isLogin = false; } return(isLogin); }
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); }
public static string secret = "a31cae562bc3de05e824ab9fa2d035b7"; //5cf839a91d5d86a953debf913f2702ec"; public static CookieContainer Login() { string alimamaAccount = File.ReadAllText("config/alimamaAccount.txt"); string posturl = "https://login.taobao.com/member/login.jhtml?redirectURL=http%3A%2F%2Flogin.taobao.com%2Fmember%2Ftaobaoke%2Flogin.htm%3Fis_login%3D1"; posturl = "https://login.taobao.com/member/login.jhtml?redirectURL=http%3A%2F%2Fwww.alimama.com"; string poststr = alimamaAccount.Split(',')[0]; //string poststr = "TPL_username=13811277391&TPL_password=tianmin3216779236&ncoSig=&ncoSessionid=&ncoToken=b642ddda7d991ecd54929e776b8a2e5341006d8a&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=¬_duplite_str=&need_user_id=&poy=&gvfdcname=10&gvfdcre=687474703A2F2F7075622E616C696D616D612E636F6D2F3F73706D3D61323139742E373636343535342E613231347472382E372E767753705056&from_encoding=&sub=&TPL_password_2=&loginASR=1&loginASRSuc=0&allp=&oslanguage=zh-CN&sr=1366*768&osVer=&naviVer=chrome%7C45.02454101&osACN=Mozilla&osAV=5.0+%28Windows+NT+10.0%3B+WOW64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F45.0.2454.101+Safari%2F537.36&osPF=Win32&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&showAssistantLink=&um_token=HV01PAAZ0be2fcc8769100dc58abe2630034bd29&ua=086%23vM3XKrXlms3XZrm6XXXXXnN70qbE80hRLkSB0NsL1OUnpSiYiIEw6f6gR7nniPZRCkHFySiYyMA37aKh8rvRg5tgz5iLtsnmXmOsTmfmyvvgH3uVP21SbwmHvE9xT5d9mr3X1WwIyO37XA5qyQGU5O3aoIJQdBDUCa6EVk31X8XOwItTyRyYRMphdoGCyT62MqdHbWqua%2BsTo8fmXmzIwv1TU8scoOsJwp1TukjPe4B9wSaaSQ1Mmr3X1WwIyO37rLbeyQGU5O3aoIJQdBDUCa6EVk31X8XOwItTyRAYI1hhdoGCyT62MqdHbWqua%2BsTo8fmXmzIwv1TUfiidxsJwp1TukjPe4B9wSaaSQ1Mmr3X1WwIyO378ejyyQGU5O3aoIJQdBDUCa6EVk31X8XOwItTyRymkLlhdoGCyT62MqdHbWqua%2BsTo8fmXmzIwv1TUfP%2BLxsJwp1TukjPe4B9wSaaSQ1MXX3XuPVV0GgUXKRLFNlk9GA7eiSm%2FaHsXX3XuPV90GKZWJRLFNeWDsn7%2BEWJ%2FuHsmr3XuWwyyO37BgY%2FyQGU7m6ho4KLw0RUCRSmXXT%2B60BBmr3XuWwByO37B0%2BEyQGU7m6ho4KLw0RUC8fmXmDIBO1TUD53%2FvsJwp8ayePHSgGVwS6tX8X%2BRVRvX40kHPMmae5mQpf2kw8dfzhIGTuVPz%2FXX8X%2FHRhB02Ei7UIB%2BQMWoLclvM78agoqX8X36ceBBGnmXmxFTTomGUMgH3usA21Sbt9fiY4oIsPuP6ySvGnmXmOsTh3mGKbgH3uvMr1SbwmHvE9xT5d9UX3X35db22mMT2mS0xPD3MrrhdIT5M55X8XRLHVmXPOPX1jzy4WR1YmsWMPLPl2mXX8f11myUr3Xmux%2BBBg%2BX8X1f6ACBymIyr3XYXXX2THi6uRTCr3Xm0YzBBoVZ%2BfmXYCpi5QrXXXbF65eAbXXXjdckE0kgXXXFL7pib02XXXB7N5eNBXXXjbWrX3mnAqiH%2FWd8wmXPh4hHRZWnVSXsrcSIunchyXL3zb2PhuIj1yFnjZWnVSXsC4BiVfSuM9xm1rqmtcXX1ckZRxZY6XX%2B%2Fbti9yMa3rpjNXtjtavmNSWWR5fZcIif2blF3rT8tnHu63e6NuR6Nrg169f4LmsJ%2FCq1D%2FeRX4x%2FtWK%2FhOPXhgJWRnD4yZW1Cm9IcXC%2FVQ7hPSOkhaij1VhJRSH4yZW1CuKUu3lmXOt3jaQ6PWMmd8ERLmDs%2FZsJ%2FCGU2xEmmQd3%2F5QhYmvPPyJ%2BAn6ZyIssTc2s3VAhrQ%2BY13ga2CzY6XRsEQOIa81Wrc7O%2Fxe1MQ7%2Fwnw6EcnXNvRIjm4%2B984kTXQFrM9RmSVhzMxDDu36z8WsA7%2BI3v6J3xyia5DOw7SEr3XY9TaBrQkJGNTjwTOQX3X1221nNtIvN4o4zn9TQ%2FJhyVyZVCm96%2FtsL8wTwrmXmUZBW3X43WXfIAT9MIfn3Qw3JIJUX3Xugdbm2mgT2mS2vPDaXnp19o8nC9fXt5kUX3X35dbEXmqT2mSf7PD3MrrhdIT5M5qX8X36ceBBwSmXXT%2B60BBUr3Xmux%2BBBgqX8X36ceBB2fmXmzIwv1TU%2FYPV7sJwp1TukjPe4B9wSaaSQ1Mmr3X1WwIyO378Sj%2FyQGU5O3aoIJQdBDUCa6EVk3XX8X%2FHR6B0MET7UIB%2Bx0DpkAolruTago%3D"; 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 = alimamaAccount.Split(',')[1]; //string strurl = "https://www.alimama.com/membersvc/my.htm?domain=taobao&service=user_on_taobao&sign_account=63f4941326712960165e9e278c31a7ad"; string resultstr = HttpHelper1.SendDataByGET(strurl, ref cc); //bool isLogin = Alimama.TestLogin(cc); return(cc); }
/// <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); }
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); }
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); }
/// <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); } }