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

简介:

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.、

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.

本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

相关文章
|
7月前
|
Web App开发 存储 缓存
Chrome 开发者工具 network 显示 Provisional headers are shown 的几种原因
Chrome 开发者工具 network 显示 Provisional headers are shown 的几种原因
241 0
|
5月前
|
数据采集 开发框架 JavaScript
基于.NET Core内置浏览器窗体应用程序界面框架
基于.NET Core内置浏览器窗体应用程序界面框架
47 0
|
XML 编解码 C#
.NET MAUI 安卓 UI 资源设置
本文主要介绍使用 MAUI 开发安卓应用时,如何更换和处理 UI 资源:应用名称,图标,主题配色,状态栏,闪屏。
439 0
.NET MAUI 安卓 UI 资源设置
|
Web App开发 开发者
Chrome开发者工具里的一个隐藏技能:chrome://net-internals
Chrome开发者工具里的一个隐藏技能:chrome://net-internals
129 0
Chrome开发者工具里的一个隐藏技能:chrome://net-internals
|
Web App开发 开发者
如何使用Chrome开发者工具调试web socket应用
如何使用Chrome开发者工具调试web socket应用
633 0
如何使用Chrome开发者工具调试web socket应用
|
Web App开发 测试技术
在 .NET 中开发基于 Chrome 内核的浏览器-创建一个简单浏览器
首先在 http://www.cftea.com/tools/downloads/Cef.zip 下载文件包。 一、将文件解压拖入到 Visual Studio 对应的 WinForm 项目中。 二、在解决方案中,在这些文件上右键,选择属性,在“复制到输出目录”中选择“始终复制”(不要忘了 locales 中的文件也要这样操作)。
1177 0
一起谈.NET技术,Silverlight实例教程 - Out of Browser在线更新和Silent安装
  Silverlight 实例教程索引 Silverlight 实例教程 - Out of Browser开篇 Silverlight 实例教程 - Out of Browser配置,安装和卸载 Silverlight 实例教程 - Out of Browser的自定义应用 Silverligh...
1068 0
|
Web App开发 C# Windows
一起谈.NET技术,Visual Studio 2010构建Web浏览器应用程序
  2001年,我使用C#中的WebBrowser ActiveX控件编写了我的第一个应用程序,点此阅读,Kapil Sony写了一篇文章介绍了C# 2.0中的WebBrowser控件,每一次.NET新版本发布,控件和功能都会发生一些变化,现在,WebBrowser控件已属于Windows Forms控件的一部分,本文是基于.NET 4.0和Visual Studio 2010完成的,如果你使用的不是Visual Studio 2010,可以去MSDN网站下载免费的Visual C# 2010 Express。
1180 0
|
Web App开发 API Windows
一起谈.NET技术,Silverlight实例教程 - Out of Browser的Debug和Notifications窗口
  Silverlight 实例教程索引 Silverlight 实例教程 - Out of Browser开篇 Silverlight 实例教程 - Out of Browser配置,安装和卸载 Silverlight 实例教程 - Out of Browser的自定义应用 Silverligh...
1041 0
一起谈.NET技术,Silverlight实例教程 - Out of Browser音乐播放器
  Silverlight 实例教程索引 Silverlight 实例教程 - Out of Browser开篇 Silverlight 实例教程 - Out of Browser配置,安装和卸载 Silverlight 实例教程 - Out of Browser的自定义应用 Silverligh...
1051 0