前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Chrome开发者工具里的一个隐藏技能:chrome://net-internals

Chrome开发者工具里的一个隐藏技能:chrome://net-internals

作者头像
Jerry Wang
发布2020-05-06 21:31:38
7650
发布2020-05-06 21:31:38
举报

During my holiday I was writing a small tool for fun, which extracts my personal posts from http://www.baidu.com 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

代码语言:javascript
复制
function getPostByAJAX(requestURL){
   var html = $.ajax({
  	url: requestURL,
  	async: false}).responseText; 
   return html;
}

The requestURL I am using is http://tieba.baidu.com/i/i/my_tie

However when I try to access it via my JavaScript code above, it failed. And Chrome development tool didn’t give me enough information for trouble shooting.

How to deal with this issue then? Then I found the useful tool from Google: chrome://net-internals Now let’s continue to trouble shoot with this tool.

(1) type chrome://net-internals in Chrome address bar, press enter key. Then click Event hyperlink.

(2) Go to my own html page which will send AJAX request via jQuery, click F5 to send a new request, then go back to Chrome tool. Now I have found the trace entry for the sent request. Here below is the request detail which contains much more information compared with the one in Chrome development Tool-Network tab.

And here below are response header fields:

The return code 302 and location “http://static.tieba.baidu.com/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 found this article from 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?

Further reading

For more tips I gained during my daily work about Chrome development tools, please refer to this blog Chrome Development Tool tips used in my daily work.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-05-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Further reading
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档