ウェブサイトの全セクションをクロールしようとしていますが、必要なデータが最初から存在しないという問題があります。 PHPを使ってウェブサイトからデータを取得する方法はありますか?クロールページは3%でしか動作しません
これはリンクです:https://www.iamsterdam.com/nl/uit-in-amsterdam/uit/agenda、これは私が必要とするセクションです:
私のポストを複製するように設定した後、私はこの https://stackoverflow.com/a/28506533/7007968を試してみましたが、また私はこれが他のsolucionを必要とするので、動作しません。私が試した何:
のget-website.php
$phantom_script= 'get-website.js';
$response = exec ('phantomjs ' . $phantom_script);
echo $response;
取得-website.js
var webPage = require('webpage');
var page = webPage.create();
page.open('https://www.iamsterdam.com/nl/uit-in-amsterdam/uit', function(status) {
console.log(page.content);
phantom.exit();
});
これは私が(ページの3%程度)取り戻すすべてです:
</div><div id="ads"></div><script src="https://analytics.twitter.com/i/adsct?p_id=Twitter&p_user_id=0&txn_id=nvk6a&events=%5B%5B%22pageview%22%2Cnull%5D%5D&tw_sale_amount=0&tw_order_quantity=0&tw_iframe_status=0&tpx_cb=twttr.conversion.loadPixels" type="text/javascript"></script></body></html>
だから私は、私は、これは検索の多くの後にどのような私です近づいてきています感があります。
var webPage = require('webpage');
var page = webPage.create();
var settings = {
operation: "POST",
encoding: "utf8",
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify({
DateFilter: 04112016,
LastMinuteTickets: 0,
PageId: "3418a37d-b907-4c80-9d67-9fec68d96568",
Skip: 0,
Take: 12,
ViewMode: 1
})
};
page.open('https://www.iamsterdam.com/api/AgendaApi/', settings, function(status) {
console.log(page.content);
phantom.exit();
});
を
しかし、私は戻って取得することは良い見ていない:
Message":"An error has occurred.","ExceptionMessage":"Page could not be found","ExceptionType":"System.ApplicationException","StackTrace":" at Axendo.SC.AM.Iamsterdam.Controllers.Api.AgendaApiController.GetResultsInternal(RequestModel requestModel)\r\n at lambda_method(Closure , Object , Object[])\r\n
など
私は幾人かが助けてくれることを願っています。
は、ページの欠落している97%についての私の答えを参照してください。 APIがうまくいかない理由については、本当にあなたが欠けているページを本当に探している可能性があります。さらに議論したい場合は、別の質問でAPIの問題について質問する必要があります。 – Vaviloff