Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8536379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:38:58+00:00 2026-06-11T10:38:58+00:00

I was trying to load a page from H&M (for studying purposes), when I

  • 0

I was trying to load a page from H&M (for studying purposes), when I noticed that the content of one div isn’t loaded, but if I save the page from the browser, the div is saved correctly.
Can anyone explain me why this happens?
The div (and most important, ist’s contents) I’m looking for is:
body>div main>div content> div relatedInformationContainer
(inside there’s lot of content: div relatedInformation>etc…)
this is the code i used:

<?php
$url = "http://www.hm.com/gb/product/05427";
libxml_use_internal_errors(true);
$html = file_get_contents($url);  
$dom = new DomDocument();  
$dom->loadHTML($html);  
$xp = new domxpath($dom);

$contentDivs = $xp->query('//div[@id="content"]')->item(0);
$numContentDivs = $xp->evaluate('count(div)', $contentDivs);
// echo $numContentDivs; // output:3 (correct)
$relatedDiv = $xp->query('//div[@id="content"]/div[2]')->item(0)->getAttribute("id");
echo $relatedDiv; // output:relatedInformationContainer (correct)
$relatedDivContent = $xp->query('//div[@id="content"]/div[2]')->item(0);
$numRelatedDivContent = $xp->evaluate('count(div)', $relatedDivContent);
echo $numRelatedDivContent; // output:0 (incorrect!!! it should output 1)
?>

I used more simple methods, same result:

<?php
$url = "http://www.hm.com/gb/product/05427";
$doc = new DOMDocument();
$load = @$doc->loadHTMLFile($url);
echo $doc->saveHTML();
?>

I would apreciate if anyone could explain me why this happens, and if there’s a solution.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:38:59+00:00Added an answer on June 11, 2026 at 10:38 am

    The DIV is loaded from Javascript. You need to retrieve what the Javascript call is, and replicate that in PHP.

    Using Firefox with Firebug, I see that the page issues a call to

    http://www.hm.com/gb/product/05427/05427-A/related
    

    which returns the DIV with all its contents (I guess it replaces the DIV). You will have to capture that.

    Also, some servers check who is asking what and on behalf of whom. So the query above might not work if its HTTP_REFERER field is not set to the correct originating page, with the right User-Agent and session cookies etc. (in general; it appears not to be the case here – even though I may be wrong).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load new content to my page from database when user scrolls
I'm trying to load a DIV element from an external page into my current
I'm trying to load one page into another using the .load() method. This loaded
I'm trying to have navigation buttons on my page load content files, but a
Hi iam trying to load googlemaps when the new page is loaded ..but itz
I'm trying to load a page using the load() function, the problem is that
I'm trying to load the dynamic content of a page as well as the
Using javascript I'm trying to load images not on the current page (from an
I'm trying to delete all the cookies that my site uses but from reading
I am trying to use PhantomJS to load a page (that uses Javascript to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.