facebook twitter hatena line email

Javascript/jqueryライブラリ/xdomainajax.js

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

jquery.xdomainajax.jsとは

jsスクレイピングcrossdomain対応プラグイン。 YQLを介して取得している様子。

注意)アクセス元IPはyahooとなる

jquery.xdomainajax.jsダウンロード

https://github.com/padolsey/jQuery-Plugins/blob/master/cross-domain-ajax/jquery.xdomainajax.js

サンプル

<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.xdomainajax.js"></script>
</head>
<body>
<script>
$.ajax({
    url: 'http://www.yahoo.co.jp/?' + encodeURI('paramdata1'),
    type: "GET",
    success: function(res) {
        console.log(res.responseText);
    },
    fail: function() {
    }
});
</script>
</body>
</html>

リモート情報

YQLからのアクセスとなるので アクセス先に記録されるリモート情報は以下の通りとなる

   [HTTP_CLIENT_IP] => [アクセス元ip]
   [HTTP_X_FORWARDED_FOR] => [アクセス元ip],  106.10.171.xx
   [HTTP_X_YQL_DEPTH] => 1
   [HTTP_USER_AGENT] => Mozilla/5.0 (compatible; Yahoo Pipes 2.0; +http://developer.yahoo.com/yql/provider) Gecko/20090729 Firefox/3.5.2
   [HTTP_VIA] => HTTP/1.1 htproxy2.ops.sg3.yahoo.net[6A0AC74D] (YahooTrafficServer/1.19.11 [uScM])
   [REMOTE_ADDR] => 106.10.199.xx
   [REMOTE_PORT] => 55888

chromeで表示してもHTTP_USER_AGENTは~Firefoxだった。YQLのブラウザがFirefoxな様子。