Chrome开发者工具里的一个隐藏技能:chrome://net-internals
During my holiday I was writing a small tool for fun, which extracts my personal posts fromhttp://www.for further analysis. I am using AJAX in jQuery to perform a synchronous call to fetch html source code of given url specified by argument requestURL.、
functiongetPostByAJAX(requestURL){varhtml=$.ajax({url:requestURL,async:false}).responseText;returnhtml;}
The requestURL I am using ishttp://tiehttp://tb/error.html?ErrType=1” give me a reminder that this issue might be related to logon state of BAIDU website, since I would like to return my personal information, it makes sense that the url can only return personal data if cookie is available or user credential is specified ( not supported by BAIDU in this case ). In order to verify my assumption, I request the url directly in Chrome and check its request header fields this time, and yes, the cookie field is there:
So now the question is, how to send my cookie information together with the AJAX call in JavaScript code? I foundthis articlefrom Google. According to the article, I add the following code in my function:
And it works now:
By the way, via this tool I can also figure out how the jQuery library file jquery1.7.1.js stored in local laptop is loaded by Chrome. Chrome reads this file by chunks with size 32768 ( the file consists of 8 chunks ).
The total size 251661 matches exactly with the number I see in windows, perfect isn’t it?
For more tips I gained during my daily work about Chrome development tools, please refer to this blogChrome Development Tool tips used in my daily work.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。