題名の通り、amazonで成功したスクレイピングがyahooでは成功しません。
amazonバージョン(成功した)
]
(画像見にくかったらすみません)
html
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 7 <title>Document</title> 8</head> 9<body> 10 11 <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script> 12 <script> 13 14 $(function () { 15 var url = 'https://www.amazon.co.jp/s/?field-keywords=mouse' 16 $.getJSON('http://www.whateverorigin.org/get?url=' + encodeURIComponent(url) + '&callback=?', function (result) { 17 var dom = $(result.contents); 18 dom.find('h2.s-access-title').each(function () { 19 console.log($(this).text()); 20 21 }); 22 }); 23 }); 24 25 26/* 27 $(function () { 28 var url = 'https://www.yahoo.co.jp/' 29 $.getJSON('http://www.whateverorigin.org/get?url=' + encodeURIComponent(url) + '&callback=?', function (result) { 30 var dom = $(result.contents); 31 dom.find('div.topicsindex > ul.emphasis > li > a ').each(function () { 32 console.log($(this).text()); 33 34 }); 35 }); 36 }); 37*/ 38</script> 39</body> 40</html> 41
コンソールに表示されたもの(結果+エラー)
Qtuo 2.4G ワイヤレスマウス 無線マウス 5DPIモード 2400DPI 高精度 ボタンを調整可能 コンパクト 省エネルギー 持ち運び便利 ブラック index2.html:19 Logicool ロジクール ワイヤレス ミニマウス ホワイト M187WH index2.html:19 mouseノートパソコン MB-B503E Celeron N3450/4GBメモリ/120GB SSD/Win 10 index2.html:19 Logicool ロジクール 有線光学式3ボタン マウス M100r ブラック index2.html:19 mouse 2in1 タブレット ノートパソコン WN892-A Windows10/Office付/8.9インチ index2.html:19 Qtuo 超静音ワイヤレス マウス無線マウス 気にならない静かなクリック音を実現 3段階の省エネモード 2.4GHz 無線マウス ブラック Mac/Windows/surface/Microsoft Proに対応 【コンパクトマウス... index2.html:19 Zelotes LED光学式5500 DPI 7ボタンUSB有線ゲーミングマウス プロゲーマー用 index2.html:19 Logicool ロジクール ワイヤレスマウス ブラック M545BK index2.html:19 Amazonベーシック USBマウス MSU0939 index2.html:19 エレコム ワイヤレスマウス 約2.5年電池交換不要 省電力 3ボタン ブラック M-FIR08DRBK index2.html:19 LOGICOOL オプティカル ゲーミングマウス G300s index2.html:19 Apple Magic Mouse カバー 吸着シリコン マウス プロテクター 《全11色》 クリア index2.html:19 Logicool ロジクール ワイヤレスマウス M235r シルバー index2.html:19 マイクロソフト マウス Bluetooth対応/ワイヤレス Designer Bluetooth Mouse 7N5-00011 index2.html:19 mouse ノートパソコン MB-BN24C432SW-ZNA Windows 10/Celeron/14インチ/SSD32GB/4GBメモリ/WPS Office index2.html:19 mouse ノートパソコン MB-B503S Windows 10/Celeron N3450/15.6型フルHD/8GBメモリ/120GB SSD/1TB HDD/Win10 index2.html:19 エレコム ワイヤレスマウス Bluetooth BlueLED 5ボタン Mサイズ ブラック M-XG1BBBK index2.html:19 Apple Magic Mouse 2 MLA02J/A index2.html:19 マイクロソフト マウス 有線/USB接続 /小型 ブラック Compact Optical Mouse for Business 4HH-00006 index2.html:19 マイクロソフト マウス ワイヤレス/小型 ブルー Sculpt Mobile Mouse 43U-00038 index2.html:19 BUFFALO 有線BlueLEDマウス 静音/5ボタンタイプ ブラック BSMBU19BK index2.html:19 LOGICOOL ワイヤレストラックボール M570t index2.html:19 AFUNTA pc用マウス Zelotes ワイヤレス ゲーミングマウス LED マウス 7段調整可能 ゲーム用 コンピューター マウス index2.html:19 マイクロソフト マウス 有線/USB接続 ブラック Basic Optical Mouse for Business 4YH-00003 index2.html:19 [スポンサー プロダクト]Qtuo 超静音ワイヤレス マウス無線マウス 気にならない静かなクリック音を実現 3段階の省エネモード 2.4GHz 無線マウス ブラック Mac/Windows/surface/Microsoft Proに対応 【コンパクトマウス... index2.html:19 [スポンサー プロダクト]Qtuo 2.4G ワイヤレスマウス 無線マウス 5DPIモード 2400DPI 高精度 ボタンを調整可能 コンパクト 省エネルギー 持ち運び便利 ブラック index2.html:19 [スポンサー プロダクト]YOHOOLYO ゲーミングマウス USBマウス ゲーマーLED光学式5500DPIマウス プロ7ボタン index2.html:19 [スポンサー プロダクト]Qtop ゲーミングマウス 光学式 マウス 500~7200dpiまで5段調節 7ボタンカスタマイズ・マクロ設定可能 ブラック 【日本語説明書付き・12ヶ月保証付き】 index2.html:19 [スポンサー プロダクト]サンワサプライ 超小型マウス ケーブル巻き取り式 ブラック MA-MA6BK index2.html:19 [スポンサー プロダクト]サンワサプライ 有線光学式マウス ブラック MA-130HUBK index2.html:1 Uncaught ReferenceError: uet is not defined at HTMLImageElement.onload (index2.html:1) onload @ index2.html:1 fls-fe.amazon.co.jp/1/batch/1/OP/A1VC38T7YXB528:355-9312175-5806458:42XE5A4EEZ56R55EKV02$uedata=s:%2Fmn%2Fsearch%2Fuedata%2F355-9312175-5806458%3Fstaticb%26id%3D42XE5A4EEZ56R55EKV02:0:1 GET file://fls-fe.amazon.co.jp/1/batch/1/OP/A1VC38T7YXB528:355-9312175-5806458:42XE5A4EEZ56R55EKV02$uedata=s:%2Fmn%2Fsearch%2Fuedata%2F355-9312175-5806458%3Fstaticb%26id%3D42XE5A4EEZ56R55EKV02:0 net::ERR_FILE_NOT_FOUND Image (async) ca @ jquery-2.2.0.min.js:3 n.parseHTML @ jquery-2.2.0.min.js:4 n.fn.init @ jquery-2.2.0.min.js:2 n @ jquery-2.2.0.min.js:2 (anonymous) @ index2.html:17 i @ jquery-2.2.0.min.js:2 fireWith @ jquery-2.2.0.min.js:2 z @ jquery-2.2.0.min.js:4 c @ jquery-2.2.0.min.js:4 dispatch @ jquery-2.2.0.min.js:3 r.handle @ jquery-2.2.0.min.js:3 aax-fe.amazon-adsystem.com/e/loi/imp?b=QoIZx4KZpoWzY8-09xniHvMAAAFfR3m2ugcAAAH2AUkJj28:1 GET file://aax-fe.amazon-adsystem.com/e/loi/imp?b=QoIZx4KZpoWzY8-09xniHvMAAAFfR3m2ugcAAAH2AUkJj28 net::ERR_FILE_NOT_FOUND
html
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 7 <title>Document</title> 8</head> 9<body> 10 11 <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script> 12 <script> 13 /* 14 $(function () { 15 var url = 'https://www.amazon.co.jp/s/?field-keywords=mouse' 16 $.getJSON('http://www.whateverorigin.org/get?url=' + encodeURIComponent(url) + '&callback=?', function (result) { 17 var dom = $(result.contents); 18 dom.find('h2.s-access-title').each(function () { 19 console.log($(this).text()); 20 21 }); 22 }); 23 }); 24*/ 25 26 27 $(function () { 28 var url = 'https://www.yahoo.co.jp/' 29 $.getJSON('http://www.whateverorigin.org/get?url=' + encodeURIComponent(url) + '&callback=?', function (result) { 30 var dom = $(result.contents); 31 dom.find('div.topicsindex > ul.emphasis > li > a ').each(function () { 32 console.log($(this).text()); 33 34 }); 35 }); 36 }); 37 38</script> 39</body> 40</html> 41
コンソールに表示されたもの(エラー)
icon_point.gif Failed to load resource: net::ERR_FILE_NOT_FOUND iconVideo_150713.gif Failed to load resource: net::ERR_FILE_NOT_FOUND info_btn-140325.gif Failed to load resource: net::ERR_FILE_NOT_FOUND logo-mh-160929.gif Failed to load resource: net::ERR_FILE_NOT_FOUND iconMail.gif Failed to load resource: net::ERR_FILE_NOT_FOUND clear.gif Failed to load resource: net::ERR_FILE_NOT_FOUND iconNew_150713.gif Failed to load resource: net::ERR_FILE_NOT_FOUND iconPhoto_150713.gif Failed to load resource: net::ERR_FILE_NOT_FOUND
ほぼ同じ構造にしているはずなのに、なぜ、このようなことが起きるのでしょうか?
回答2件
あなたの回答
tips
プレビュー