This is a further question of this post. Actually this code from SqRoots.And this code has completed the task.
(I assume you are using Mozilla Firefox and MMA version 11.0)
Needs["DatabaseLink`"];
conn=OpenSQLConnection[JDBC["SQLite",First[FileNames["cookies.sqlite",ParentDirectory[$UserBaseDirectory]<>"\\Mozilla\\Firefox\\Profiles\\",Infinity]]]];
c=SQLExecute[conn,"select * from moz_cookies where baseDomain like '%.stackexchange.com'"];
cookie=<|"Domain"->#[[-3]],"Name"->#[[2]],"Content"->#[[3]],"Path"->#[[-2]],"ExpirationDate"->#[[-1]]|>&/@c[[;;,{2,4,5,6,7,8}]];
t=URLRead["https://mathematica.stackexchange.com/users/21532/yode?tab=favorites","Body",VerifySecurityCertificates->True,{Cookies->cookie},CharacterEncoding->"UTF-8"];
file=ExpandFileName[Export["testt.txt",t]];
Quiet[DeleteFile[StringReplace[file, "txt" -> "html"]]];
File@RenameFile[file,StringReplace[file,"txt"->"html"]]//SystemOpen
After you run this code,you will get the website like:
http://o8aucf9ny.bkt.clouddn.com/2016-09-07-17-26-33.png
This is what I want exactly.But I'm a little unhappy with the use of package DatabaseLink
and that command of SQL.I think we can use the new function FindCookies
to replace it.But I don't know how to realize it.
Question: How to use FindCookies
to get that cookie
?
Comments
Post a Comment