【未解决】python中如何支持用户名和密码登陆skydrive
【背景】
想要在python脚本中,用自己的用户名和密码,登陆skydrive,使得脚本中就可以获得所有的内容,
以便后面的处理,用脚本去解析出所有文件的真实的地址。
【解决过程】
参考资料:
http://hi.baidu.com/moioo/blog/item/4f6f1d5c4827ed4bfbf2c00a.html
——————————————————————————–
(1)对于skydrive:
未登陆的情况下,登陆:
https://skydrive.live.com/
会跳转到对应的地址:
IE:
https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1325914597&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F%3Flc%3D2052&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1325914616&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky
chrome:
https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1325914855&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky
(2)对于Hotmail:
地址是:
IE:
https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1325922588&rver=6.1.6206.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=2052&id=64855&mkt=zh-cn&cbcxt=mai&snsc=1
下面是从源码中得到的一些js脚本,其中抽取出相关的内容:
-------------------------------------------------------------------------------- Main_WLStrings_JS2052__formated.js g_s["ii2"] = "Windows Live ID:"; g_s["ii11"] = "登录"; -------------------------------------------------------------------------------- WLWorkflow__formated.js WJ = function (e, d, c, f) { var b = this; b.m_arrTasks = []; if (exists(e)) { for (var a = 0; a < e.length; a++) { b.m_arrTasks.push([function (a, b) { this [a] = b; }, [e[a][0], e[a][1]]]); } } if (exists(d)) { for (var a = 0; a < d.length; a++) { b.m_arrTasks.push([function (a, b) { this.style[a] = b; }, [d[a][0], d[a][1]]]); } } if (exists(c)) { for (var a = 0; a < c.length; a++) { b.m_arrTasks.push([function (b, a) { this [b].apply(this, a) }, [c[a][0], c[a][1]]]); } } if (exists(f)) { b.evtName = f; b.stateName = f + "uistate"; } }; function _di(H, d) { var y = "21px", r = "u2", x = "ii11", j = "height", F = "idSubmit_PWD_SignIn", b = null; a.set(i, UI.ID, F); a.set(i, UI.Input, InputType.Submit); a.set(i, UI.Name, "SI"); a.set(i, UI.State, new WJ(b, [[j, "25px"]])); a.set(i, UI.String, g_s[x]); a.set(l, UI.ID, "idTxtBx_PWD_Username"); a.set(l, UI.Input, InputType.TxtBx); a.set(l, UI.Name, "login"); a.set(l, UI.State, g_stateUserTxtBx); a.set(m, UI.ID, "idTxtBx_PWD_Password"); a.set(m, UI.Input, InputType.Pwd); a.set(m, UI.Name, "passwd"); a.set(m, UI.State, g_statePwdTxtBx); a.set(r, UI.ID, F); a.set(r, UI.Input, InputType.Submit); a.set(r, UI.State, new WJ(b, [[j, y]])); a.set(r, UI.String, g_s[x]); } function createIDMod(a) { return function (b) { if (exists(b)) { if (b == "idLbl_Tile_Username" && (a == 1 || a == "1")) { return "SUName0"; } if (a == "0Pwd") { if (b == "idTxtBx_PWD_Username") { return "i0116"; } if (b == "idTxtBx_PWD_Password") { return "i0118"; } if (b == "idSubmit_PWD_SignIn") { return "idSIButton9"; } if (b == "idChkBx_PWD_RememberMe") { return "i0201"; } if (b == "idChkBx_PWD_SavePassword") { return "i0202"; } } b += a } return b; } }
——————————————————————————–
https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1325916670&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky
in chrome, 开发人员工具
对着“登陆”右击 -> 审查元素,可以找到:
(1) 登陆 按钮的html源码:
<input type="submit" name="SI" id="idSIButton9" value="登录" style="height: 25px; ">
(2) 用户名输入框
<input type="text" name="login" id="i0116" maxlength="113" class="cssTextInput">
(3) 密码输入框
<input name="passwd" type="password" id="i0118" maxlength="16" autocomplete="off" class="cssTextInput">
================================================================================
点击“登陆”按钮后,进入了:
https://skydrive.live.com/
对应chrome中分析出来的内容中,点击Other可以找到post.srf
未解析的数据是:
Request URL:https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct=1325916670&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky&bk=1325918670 Request Method:POST Status Code:302 Found Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:zh-CN,zh;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Content-Length:483 Content-Type:application/x-www-form-urlencoded Cookie:CkTst=G1325918685495; wlp=A|eyJV-t:a*RSWtBQ._; MSPShared=1; SAToken=RDWTVRXJDLVZUPZFWUCRECNRJTJDUBUDVSAFAAACELZJ; HIC=9a8b8bf501a38a36|1|104|; xid=cabcb62a-9e26-4d0a-bc9b-d7fe86599e28&&BL2xxxxxxC619&39; xidseq=1; wla42=cHJveHktYmF5LnB2dC1jb250YWN0cy5tc24uY29tfGJ5MioxLDlBOEI4QkY1MDFBMzhBMzYsMSwwLDA=; MSPRequ=lt=1325916671&co=1&id=250206; CkTst=G1325916686718; wlidperf=throughput=3&latency=856&FR=L&ST=1325918683953; MSPOK=$uuid-a150a6a9-e2d0-41a2-b83e-b234d4c6c68c$uuid-96bb45bd-5087-4c05-a310-a4fad5ac892e; wl_preperf=req=131&com=131&cache=129 Host:login.live.com Origin:https://login.live.com Referer:https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct=1325916670&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky&bk=1325916671 User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7 Query String Parametersview URL encoded wa:wsignin1.0 rpsnv:11 ct:1325916670 rver:6.1.6206.0 wp:MBI_SSL_SHARED wreply:https://skydrive.live.com/ lc:2052 id:250206 mkt:zh-CN cbcxt:sky bk:1325918670 Form Dataview URL encoded login:[email protected] passwd:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX SI:登录 type:11 LoginOptions:3 NewUser:1 MEST: PPSX:PassportR PPFT:CvrmjiWWG1MBEBqU58ic9t0Zbd2mt7Ph5z7ilAYQMQcvKJ1m2TLaFQNIM8vCvfxdeuZCefGNgPx8YHQquAhrXLF***aCYBc2LW40k1RroDW0caYxtGLqeLOu9Rh2cBok05xJTM46AbSYbyxANJ7joIp9MfGfvlJGORYyse1HkK3HAqsUKtcF38rSF6whvehzZRCyvPX3imtnoOkM1UgmK14vWYriPNBSosXmSwy1T02CiBkecrAfIp*hhwfULpaSFA$$ idsbho:1 PwdPad: sso: i1: i2:1 i3:306367 i4: i12:1 i13: i14:148 i15:1086 i16:1640 i17: Response Headersview source Cache-Control:no-cache Connection:close Content-Length:0 Content-Type:text/html; charset=utf-8 Date:Sat, 07 Jan 2012 06:49:37 GMT Expires:Sat, 07 Jan 2012 06:48:38 GMT Location:https://skydrive.live.com/ P3P:CP="DSP CUR OTPi IND OTRi ONL FIN" PPServer:PPV: 30 H: BAYIDSLGN1H58 V: 0 Pragma:no-cache Server:Microsoft-IIS/7.5 Set-Cookie:MSPOK=$uuid-a150a6a9-e2d0-41a2-b83e-b234d4c6c68c; domain=login.live.com;path=/;version=1 PPAuth=Cq4x!1ZOqUeOpftcaVYRnBP3R*VCvmyvtnzS*Sg57ncMd*dgiDA6O0I6qfpMcyUol*zR3RKqroPUIjDRTDPsw81cPvcafwaCjZE3g5vAs8cdhEzkLbmdxy3TnHu7PHv8DDO19UuNzwF36CoZcj1kQ5Z13f9VplantS2auvja218DCX6r7F1wEK0YjUnY1UrHyxBWUAQocfIOdkyZFrvcWC658hGPtBgue6zJWV!XF0a8wb7IaVXKEyvyX!KxdpXKdTdZcmSvaSrM!QjIcB4CHEvrGsv2W3lMGCChNP4jj2C*; domain=login.live.com;secure= ;path=/;HTTPOnly= ;version=1 PPLState=1; domain=.live.com;path=/;version=1 MSPShared=1; expires=Wed, 30-Dec-2037 16:00:00 GMT;domain=login.live.com;path=/;HTTPOnly= ;version=1 MSPPre= ;domain=login.live.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT MSPCID= ; HTTPOnly= ; domain=login.live.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT RPSTAuth=EwDwARAnAAAUWkziSC7RbDJKS1VkhugDegv7L0eAAJsWPAE8DksRVoh2xsX4bZa6/svgW1L09ILs8mhjBMTsssRXUsbrncmF3E82BZrDWXdPWHHZd5aMiIU2LW9C+J9X3/cyzgngDxlhV8lKrqZ/VDvZSQfvdwrXLFXK1wPVWTpe27iURq+S5lDCwkBKT/gmGAV/0+e0H4ngvU4VlQh8A2YAAAjk7dp/EWwSbUABJ4M/PwQGQjweWrFia4jPP7xEAQW/kMyFWWoZsHXeUrjZjW7kTFiBVtoFTlXhCRHoyeQFvxergWiyUsG0wqb8AmCYpXpKIisl5xXie427yEcmijcjlM9WgbzP26RLdMu7P3kcdqHjUABfYA7o25knKvZ+vgw1hBBKRckQ9YgrRmazAiQ9EKi6bHXy/lH/4pGCWpoiyjDbpYeQNwFnDO5EjYpqS/5Cv+F+D2qgo3NEpL7zyThD4xme3ogUcVVvOAK3b1FN80m2rql725Mvne9VihMnLTrgsix7Me+U+veLwWxF0xu+EhfSqy62WMnCJMG9eHAGgJsdMiMyCIhQ2Z2XNMdT92GZj8/Tlls6Butp59/fbETv2Hnd+S3vZ5wC2/4OQOI03hnw/tuSEEZE0uVAwmYjC/TCQvgWESKsndNfpqtpAQ==; domain=.live.com;path=/;HTTPOnly= ;version=1 RPSTAuthTime=1325918978; domain=login.live.com;path=/;HTTPOnly= ;version=1 MSPAuth=2AtNZO6vZDkFrasI*6mkOWWgOK68EmV8YSPyYeRRWK8QAmlfQGNke0oTYZ5VcB!YdnrnBv6vrWjJ!qpRSdLcNrPyXm2fnnTweKZdBM6vO2vqCR4BOQcxjhGI1cRpweorBf; domain=.live.com;path=/;HTTPOnly= ;version=1 MSPProf=2TPysZTabDqAxlfq0BGQI*nhUZO7NS1xLk4LB!6AdPJLIl3kA88okLwiFY4CavrYgPOYe76CJwqmxC0uDf*GpOLC2hNbVA*0Iy*tc20pqpLTpPR3g*C31YZCJ5KAU7z0ztyN8vf!t1S8qPa4rECP0AGT07R3nqnVaeaTEzf5k8Ub8biU7mDCVb8UR98t2AFKmz; domain=.live.com;path=/;HTTPOnly= ;version=1 MSNPPAuth=CkIK9fVb5hN6sbClzfS8lrV7PzZK1l2qWjXjdvjWZVl5c9vLhNFeNPA6M4yEdvpsDZuHc5Z2NulqV1itahPIdjjpZ3mtrpqcuI3RX2V5HvEBLSWGfr3FEvywgNDcejuRYOIhBn3s*HNXZupwE79MHvnrTynX2Pi1VcZ!gZxg4knsn*HhMlzkIBBWoGlkYUOc*67*Am7ND1ulC7CWsWyoYPTcd5b*zpC26JkwJ6ZKlDqZ*roVF6c7YkIVTzIAUeHyIcQj3deQxXYHebGP6ofQXEjH0bHIuhhjJ3i9J5WKGGDNZiqjocgynsJu3pZrhZZGfBr6lEURzz6lx0YNCeHlLvwP!ghxdJsG0giTYVjrRMfjPbII7QRuMxMPDpzAEf6*uP9rzgSCgaitXayA5QlYF7Wqtw*JguLSRfi14o597SDjkmP93Ol56x2kEAtNeXyshNbeds6LSnixLNmhPOWYdPfZARuJe5!PqoPkHUKK77RWn1RYLAIu0cKerdGwQfmI0w$$; domain=.live.com;path=/;HTTPOnly= ;version=1 MH=MSFT; domain=.live.com;path=/;version=1 MHW=; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.live.com;path=/;version=1 MHList=; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.live.com;path=/;version=1 NAP=V=1.9&E=bca&C=px48IE5oaai16l94UrHsMS20EmxOaBfI1jr_TjF5ynYLnVe3uEMiCQ&W=1;domain=.live.com;path=/ ANON=A=DE389D4D076BF47BCAE4DC05FFFFFFFF&E=c24&W=1;domain=.live.com;path=/ MSPVis=$9;domain=login.live.com;path=/ pres=; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.live.com;path=/;version=1 LOpt=0; domain=login.live.com;path=/;version=1 WLSSC=EgBpAQMAAAAEgAAACoAAZAsB9jI9wEyNrDsCP9y/RPF/kudiF8A+Jge2G2LEG+CnPqfuEVZpt+PrSSjbXlFNWNcFA2eElf/5ogMf7FQPp32NXraZJKE/ghHlnZm8uuxlLVt+d5X/R/a3L/vp7hkbiJ/zbVYyPSpwjL+9sHGSachE3e5mg3hHKe3BuPiTTzTYAFwA2AD9vwYA7VazlwLrB08C6wdPECcAAAoQoAAAFwBjcmlmYW4yMDAzQGhvdG1haWwuY29tAE8AABZjcmlmYW4yMDAzQGhvdG1haWwuY29tAAAACUNOAAYyMTM1OTIAAAZlCAQCAAB3F21AAARDAAR0aWFuAAR3YW5nBMgAAUkAAAAAAAAAAAAAAaOKNpqLi/UAAALrB08CYBpPAAAAAAAAAAAAAAAAEAAxMjEuMjI3LjI1NS4xMTcABQAAAAAAAAAAAAAAAAEEBAEAAAEAAAEAAAAAAAAAAA==; domain=.live.com;secure= ;path=/;HTTPOnly= ;version=1 MSPSoftVis=@72198325083833620@:@; domain=login.live.com;path=/;version=1 X-Content-Type-Options:nosniff X-XSS-Protection:0
解析后的数据是:
Request URL:https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct=1325916670&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky&bk=1325918670 Request Method:POST Status Code:302 Found Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:zh-CN,zh;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Content-Length:483 Content-Type:application/x-www-form-urlencoded Cookie:CkTst=G1325918685495; wlp=A|eyJV-t:a*RSWtBQ._; MSPShared=1; SAToken=RDWTVRXJDLVZUPZFWUCRECNRJTJDUBUDVSAFAAACELZJ; HIC=9a8b8bf501a38a36|1|104|; xid=cabcb62a-9e26-4d0a-bc9b-d7fe86599e28&&BL2xxxxxxC619&39; xidseq=1; wla42=cHJveHktYmF5LnB2dC1jb250YWN0cy5tc24uY29tfGJ5MioxLDlBOEI4QkY1MDFBMzhBMzYsMSwwLDA=; MSPRequ=lt=1325916671&co=1&id=250206; CkTst=G1325916686718; wlidperf=throughput=3&latency=856&FR=L&ST=1325918683953; MSPOK=$uuid-a150a6a9-e2d0-41a2-b83e-b234d4c6c68c$uuid-96bb45bd-5087-4c05-a310-a4fad5ac892e; wl_preperf=req=131&com=131&cache=129 Host:login.live.com Origin:https://login.live.com Referer:https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct=1325916670&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky&bk=1325916671 User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7 Query String Parametersview decoded wa:wsignin1.0 rpsnv:11 ct:1325916670 rver:6.1.6206.0 wp:MBI_SSL_SHARED wreply:https:%2F%2Fskydrive.live.com%2F lc:2052 id:250206 mkt:zh-CN cbcxt:sky bk:1325918670 Form Dataview decoded login:crifan2003%40hotmail.com passwd:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX SI:%E7%99%BB%E5%BD%95 type:11 LoginOptions:3 NewUser:1 MEST: PPSX:PassportR PPFT:CvrmjiWWG1MBEBqU58ic9t0Zbd2mt7Ph5z7ilAYQMQcvKJ1m2TLaFQNIM8vCvfxdeuZCefGNgPx8YHQquAhrXLF***aCYBc2LW40k1RroDW0caYxtGLqeLOu9Rh2cBok05xJTM46AbSYbyxANJ7joIp9MfGfvlJGORYyse1HkK3HAqsUKtcF38rSF6whvehzZRCyvPX3imtnoOkM1UgmK14vWYriPNBSosXmSwy1T02CiBkecrAfIp*hhwfULpaSFA%24%24 idsbho:1 PwdPad: sso: i1: i2:1 i3:306367 i4: i12:1 i13: i14:148 i15:1086 i16:1640 i17: Response Headersview source Cache-Control:no-cache Connection:close Content-Length:0 Content-Type:text/html; charset=utf-8 Date:Sat, 07 Jan 2012 06:49:37 GMT Expires:Sat, 07 Jan 2012 06:48:38 GMT Location:https://skydrive.live.com/ P3P:CP="DSP CUR OTPi IND OTRi ONL FIN" PPServer:PPV: 30 H: BAYIDSLGN1H58 V: 0 Pragma:no-cache Server:Microsoft-IIS/7.5 Set-Cookie:MSPOK=$uuid-a150a6a9-e2d0-41a2-b83e-b234d4c6c68c; domain=login.live.com;path=/;version=1 PPAuth=Cq4x!1ZOqUeOpftcaVYRnBP3R*VCvmyvtnzS*Sg57ncMd*dgiDA6O0I6qfpMcyUol*zR3RKqroPUIjDRTDPsw81cPvcafwaCjZE3g5vAs8cdhEzkLbmdxy3TnHu7PHv8DDO19UuNzwF36CoZcj1kQ5Z13f9VplantS2auvja218DCX6r7F1wEK0YjUnY1UrHyxBWUAQocfIOdkyZFrvcWC658hGPtBgue6zJWV!XF0a8wb7IaVXKEyvyX!KxdpXKdTdZcmSvaSrM!QjIcB4CHEvrGsv2W3lMGCChNP4jj2C*; domain=login.live.com;secure= ;path=/;HTTPOnly= ;version=1 PPLState=1; domain=.live.com;path=/;version=1 MSPShared=1; expires=Wed, 30-Dec-2037 16:00:00 GMT;domain=login.live.com;path=/;HTTPOnly= ;version=1 MSPPre= ;domain=login.live.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT MSPCID= ; HTTPOnly= ; domain=login.live.com;path=/;Expires=Thu, 30-Oct-1980 16:00:00 GMT RPSTAuth=EwDwARAnAAAUWkziSC7RbDJKS1VkhugDegv7L0eAAJsWPAE8DksRVoh2xsX4bZa6/svgW1L09ILs8mhjBMTsssRXUsbrncmF3E82BZrDWXdPWHHZd5aMiIU2LW9C+J9X3/cyzgngDxlhV8lKrqZ/VDvZSQfvdwrXLFXK1wPVWTpe27iURq+S5lDCwkBKT/gmGAV/0+e0H4ngvU4VlQh8A2YAAAjk7dp/EWwSbUABJ4M/PwQGQjweWrFia4jPP7xEAQW/kMyFWWoZsHXeUrjZjW7kTFiBVtoFTlXhCRHoyeQFvxergWiyUsG0wqb8AmCYpXpKIisl5xXie427yEcmijcjlM9WgbzP26RLdMu7P3kcdqHjUABfYA7o25knKvZ+vgw1hBBKRckQ9YgrRmazAiQ9EKi6bHXy/lH/4pGCWpoiyjDbpYeQNwFnDO5EjYpqS/5Cv+F+D2qgo3NEpL7zyThD4xme3ogUcVVvOAK3b1FN80m2rql725Mvne9VihMnLTrgsix7Me+U+veLwWxF0xu+EhfSqy62WMnCJMG9eHAGgJsdMiMyCIhQ2Z2XNMdT92GZj8/Tlls6Butp59/fbETv2Hnd+S3vZ5wC2/4OQOI03hnw/tuSEEZE0uVAwmYjC/TCQvgWESKsndNfpqtpAQ==; domain=.live.com;path=/;HTTPOnly= ;version=1 RPSTAuthTime=1325918978; domain=login.live.com;path=/;HTTPOnly= ;version=1 MSPAuth=2AtNZO6vZDkFrasI*6mkOWWgOK68EmV8YSPyYeRRWK8QAmlfQGNke0oTYZ5VcB!YdnrnBv6vrWjJ!qpRSdLcNrPyXm2fnnTweKZdBM6vO2vqCR4BOQcxjhGI1cRpweorBf; domain=.live.com;path=/;HTTPOnly= ;version=1 MSPProf=2TPysZTabDqAxlfq0BGQI*nhUZO7NS1xLk4LB!6AdPJLIl3kA88okLwiFY4CavrYgPOYe76CJwqmxC0uDf*GpOLC2hNbVA*0Iy*tc20pqpLTpPR3g*C31YZCJ5KAU7z0ztyN8vf!t1S8qPa4rECP0AGT07R3nqnVaeaTEzf5k8Ub8biU7mDCVb8UR98t2AFKmz; domain=.live.com;path=/;HTTPOnly= ;version=1 MSNPPAuth=CkIK9fVb5hN6sbClzfS8lrV7PzZK1l2qWjXjdvjWZVl5c9vLhNFeNPA6M4yEdvpsDZuHc5Z2NulqV1itahPIdjjpZ3mtrpqcuI3RX2V5HvEBLSWGfr3FEvywgNDcejuRYOIhBn3s*HNXZupwE79MHvnrTynX2Pi1VcZ!gZxg4knsn*HhMlzkIBBWoGlkYUOc*67*Am7ND1ulC7CWsWyoYPTcd5b*zpC26JkwJ6ZKlDqZ*roVF6c7YkIVTzIAUeHyIcQj3deQxXYHebGP6ofQXEjH0bHIuhhjJ3i9J5WKGGDNZiqjocgynsJu3pZrhZZGfBr6lEURzz6lx0YNCeHlLvwP!ghxdJsG0giTYVjrRMfjPbII7QRuMxMPDpzAEf6*uP9rzgSCgaitXayA5QlYF7Wqtw*JguLSRfi14o597SDjkmP93Ol56x2kEAtNeXyshNbeds6LSnixLNmhPOWYdPfZARuJe5!PqoPkHUKK77RWn1RYLAIu0cKerdGwQfmI0w$$; domain=.live.com;path=/;HTTPOnly= ;version=1 MH=MSFT; domain=.live.com;path=/;version=1 MHW=; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.live.com;path=/;version=1 MHList=; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.live.com;path=/;version=1 NAP=V=1.9&E=bca&C=px48IE5oaai16l94UrHsMS20EmxOaBfI1jr_TjF5ynYLnVe3uEMiCQ&W=1;domain=.live.com;path=/ ANON=A=DE389D4D076BF47BCAE4DC05FFFFFFFF&E=c24&W=1;domain=.live.com;path=/ MSPVis=$9;domain=login.live.com;path=/ pres=; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=.live.com;path=/;version=1 LOpt=0; domain=login.live.com;path=/;version=1 WLSSC=EgBpAQMAAAAEgAAACoAAZAsB9jI9wEyNrDsCP9y/RPF/kudiF8A+Jge2G2LEG+CnPqfuEVZpt+PrSSjbXlFNWNcFA2eElf/5ogMf7FQPp32NXraZJKE/ghHlnZm8uuxlLVt+d5X/R/a3L/vp7hkbiJ/zbVYyPSpwjL+9sHGSachE3e5mg3hHKe3BuPiTTzTYAFwA2AD9vwYA7VazlwLrB08C6wdPECcAAAoQoAAAFwBjcmlmYW4yMDAzQGhvdG1haWwuY29tAE8AABZjcmlmYW4yMDAzQGhvdG1haWwuY29tAAAACUNOAAYyMTM1OTIAAAZlCAQCAAB3F21AAARDAAR0aWFuAAR3YW5nBMgAAUkAAAAAAAAAAAAAAaOKNpqLi/UAAALrB08CYBpPAAAAAAAAAAAAAAAAEAAxMjEuMjI3LjI1NS4xMTcABQAAAAAAAAAAAAAAAAEEBAEAAAEAAAEAAAAAAAAAAA==; domain=.live.com;secure= ;path=/;HTTPOnly= ;version=1 MSPSoftVis=@72198325083833620@:@; domain=login.live.com;path=/;version=1 X-Content-Type-Options:nosniff X-XSS-Protection:0
关于Python中支持用户名和密码登陆网站,此处是skydrive,的问题,
参考:
使用 Python 登录网站
http://xiaofeng1982.blog.163.com/blog/static/315724582011717104155265/
python类库31[httplib2处理http的get和post]
http://www.cnblogs.com/itech/archive/2011/01/10/1931946.html
python http post数据表单
http://qlj.sh.cn/python/20100330/pythonhttp-post/
最后都还是没搞定,主要原因好像是由于上述form data,内容实在太多。
而想要成功发送http请求,看来是要好好分析相关的javascript的,找到如何够着这些数据,如何获得这些数据的,
都搜集齐了这些要发送的数据,再去打开对应的url,估计才可以正确登陆skydrive,才可以看到对应账户下面所有的内容。
这部分分析工作,暂时搁置,等有空再折腾。
此时未完成的代码,先贴在这里:
—————————未完成的python代码———————————-
# add support for usr and pwd to login # cookie cj = cookielib.LWPCookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) # Login username = '[email protected]' password = 'xxxxxxxxxxx' paraDict = { 'login' : username, 'passwd': password, 'type' :'11', } paraStr = urllib.urlencode(paraDict) print "paraStr=",paraStr #paras = '' #paras += '&' + 'login=' + username #paras += '&' + 'passwd=' + password #reqUrl = 'https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct=1325919457&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky&bk=1325919458' reqUrl = 'https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct=1325923064&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F%3Flc%3D2052&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky&bk=1325925050' #reqUrl += '&' + 'login=' + username #reqUrl += '&' + 'passwd=' + password allParaDict = { 'login' : username, #'passwd': password, 'SI' : '登录', 'type' : '11', 'LoginOptions' : '3', 'NewUser' : '1', 'MEST' : '', 'PPSX' : 'Passport', 'PPFT' : 'CtP9*nkEd7prAUAONB0PVbcNmD8HJnwse3BpTP0*WMOReb2dK0r3Yciz95EhtjWtpECPMiXBeGnvog8rhZwIfJaCWA91VW0WFkS7msrIjJW1UmvCR*ur50bidx5zRhRxLP9GCgOCnwrMVgctkSp5zhN4t2cF6*T2pXaDQla8e14ntECvakCgYH3dy!Wljordy5cKqE7ajDPVm1QbXziV4f72j7GA22Xg2Yj1W7np7WsxNtBV0tTgM*41xmsM9N0opA$$', 'idsbho': '1', 'PwdPad': '', 'sso' : '', 'i1' : '', 'i2' : '1', 'i3' : '13444', 'i4' : '', 'i12' : '1', 'i13' : '', 'i14' : '151', 'i15' : '1298', 'i16' : '1458', 'i17' : '', } allParaStr = urllib.urlencode(allParaDict) allParaStr += '&passwd=' + password print "allParaStr=",allParaStr #httplib2 urlstr = reqUrl conn = httplib2.Http('.cache') headers = { 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Charset' : 'GBK,utf-8;q=0.7,*;q=0.3', 'Accept-Encoding' : 'gzip,deflate,sdch', 'Accept-Language' : 'zh-CN,zh;q=0.8', 'Cache-Control' : 'max-age=0', 'Connection' : 'keep-alive', #'Content-Length' : '486', 'Content-Type' : 'application/x-www-form-urlencoded', 'Host' : 'login.live.com', 'Origin' : 'https://login.live.com', 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7', 'Referer' : 'https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1325926841&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https%3A%2F%2Fskydrive.live.com%2F%3Fcid%3D9a8b8bf501a38a36&lc=2052&id=250206&mkt=zh-CN', 'Cookie' : 'CkTst=G1325925918281; wlp=A|eyJV-t:a*RSWtBQ._; mkt=ep=zh-CN; MUID=1D39A0945AE56E6D20D0A2745EE56EDD; wls=A|eyJV-t:a*Sn; MSPShared=1; MH=MSFT; NAP=V=1.9&E=bca&C=qtz934U8YvAH2FXXMLD9moXq4XuWK7nNVgCZUvO_JbiCG5GjTinn_w&W=1; ANON=A=DE389D4D076BF47BCAE4DC05FFFFFFFF&E=c24&W=1; MSPBack=1325925919; wlxS=WebIM=1&wpc=1; HIC=9a8b8bf501a38a36|1|104|; pres=9a8b8bf501a38a36=1; IgnoreCAW=1; MSPSoftVis=@:@; xid=b7f6e63f-4de1-449e-8134-e8bdfdf99246&&BL2xxxxxxC538&39; xidseq=19; E=P:fjdb9zGbzog=:crZVWLdjcyCGUUt9WQSYVHgRmGt0v65V86lfEld9gQU=:F; wlv=A|_-d:s*OYeOBw.2+1+0+3|eyJV-d:s*UneOBw.2+1+0+3; SAToken=; SLVersion=4.0.50401; SLSupportedAgent=true; wla42=cHJveHktYmF5LnB2dC1jb250YWN0cy5tc24uY29tfGJ5MioxLDlBOEI4QkY1MDFBMzhBMzYsMSwwLDA=; LD=b7f6e63f-4de1-449e-8134-e8bdfdf99246_0136bc4fe14_15217_1325926855307=E2057~ReadWrite.Content.Folder~ResourceID:root~SSEntry:None~ViewMethod:Browse~DataSource:SkyDrive|E2063~ClickedSelected.Command.SkyDrive~SkyCmnd:DV~ClickLoc:CB|L2127|N16833~~~L; LN=x6fbr1325926872140%266bc4%2611; BP=l=SDX.Skydrive&FR=SDX.Skydrive%2AFiles.default.F.U&ST=1325926872146&p=0; MSPRequ=lt=1325926859&id=250206&co=1; MSPOK=$uuid-d48e9723-adc9-4cae-9cea-5c58e81b672f$uuid-05446d88-857e-410f-851e-dc134a08c8a1$uuid-d179ba2e-1bdf-4e5b-a032-0e83cfee2239$uuid-9efe1aaf-204d-48c4-983c-b09a25dcf91a$uuid-47207ee1-5d9c-41ab-a7ed-409f5af2d6dd; CkTst=G1325926874011; wl_preperf=req=131&com=131&cache=129; wlidperf=throughput=2&latency=1304&FR=L&ST=1325926882439' } (response, content) = conn.request(urlstr, 'POST', allParaStr, headers) #conn = httplib.HTTPConnection("https://skydrive.live.com/") #conn.request('POST', '', allParaStr, headers) #openRet = urllib2.urlopen(urlstr, allParaStr) #logging.info("open return: %s", openRet.read()) #logging.info("response=%s",response) logging.debug("content=%s",content)
——————————————————————————-
转载请注明:在路上 » 【未解决】python中如何支持用户名和密码登陆skydrive