1

I have a weird problem. I've been using Simple Html Dom library for a while now, but trying to load a certain page always returns content in an array, and not HTML. I'm stumped.

This is the code:

$target_url = "https://www.bol.com/nl/p/foscam-fi9928p-1080p-ptz-dome/9200000075190022/prijsoverzicht/";
    $html->load_file($target_url);
    echo "$html";

I've also tried file_get_contents and file_get_html, as wel as tried with a cURL library; they all return an array. Also it only appears to happen on these overview pages, not on product pages themselves.

1 Answer 1

2

The reason is probably that bol.com returns JSON.

  Content-Type: application/json;charset=UTF-8
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the quick answer. Where do you find the content-type of that page? Also do you happen to know if there's a way I can request the page without the content-type being json?
I did a "wget -S" of your URL, one of the headers was "Content-Type". No, you can tell bol what you accept as content-type, with the "Accept" header, as in "Accept: text/html", and they will return HTML. Others might not be so kind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.