dimanche 7 juillet 2019

file_get_contents is showing failed to open stream: HTTP request failed! HTTP/1.1 406 Not Acceptable for particular website

I am using file_get_contents to get data. It is working fine in most sites. But it is showing error for a particular website. Here is one of them : https://wikivisually.com/wiki/Bamboo-copter

I have also used curl for this but does not work for that particular website.

    $html = file_get_contents('https://wikivisually.com/wiki/Bamboo-copter');

    $dom = new \domDocument;
    $dom->loadHTML($html);
    $dom->preserveWhiteSpace = false;
    $images = $dom->getElementsByTagName('img');
    $imageList['matchedImages'] = [];
    $imageList['possibleMatches'] = [];
    $searchtags = $request->searchtags;
    $i = 0; $j = 0;
    foreach ($images as $image) {
        $src = $image->getAttribute('src');
    }

It shows file_get_contents(https://wikivisually.com/wiki/Bamboo-copter): failed to open stream: HTTP request failed! HTTP/1.1 406 Not Acceptable. I want to get the list of the image files




Aucun commentaire:

Enregistrer un commentaire