JS GET请求解析

时间:2014-02-15 16:54:00

标签: javascript php curl get

我有一个只有Google Analytics Universe代码的简单页面http://mellowkids.ru/serv-ga/test.php

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-44059933-1', 'mellowkids.ru');
  ga('send', 'pageview');

</script> 

在Chrome开发者工具中,我可以看到analytics.js使用一些参数生成对http://www.google-analytics.com/collect(gif像素)的js查询。 enter image description here

这样的事情:

curl 'http://www.google-analytics.com/collect?v=1&_v=j16&a=1674396045&t=pageview
&_s=1&dl=http%3A%2F%2Fmellowkids.ru%2Fserv-ga%2Ftest.php&ul=ru&de=UTF-8...

我如何抓住此链接(卷曲)并通过echo或其他内容在页面中打印?

1 个答案:

答案 0 :(得分:0)

我相信您需要一个浏览器(它可能像PhantomJS那样无头。)

对于PhantomJS,通过netlognetsniff或类似的东西,您将能够捕获所需的GET请求(即http://www.google-analytics.com/collect?v=1&_v=j16&a=...)并在任何需要的地方打印。