Note that there are some explanatory texts on larger screens.

plurals
  1. POget div conents from external url - best method - PHP? DOM? jQuery?
    primarykey
    data
    text
    <p>I am trying to get the contents of a div from the id name.</p> <p>Here is the div I am trying to get: <code>&lt;div id="article-body"&gt; ... &lt;/div&gt;</code></p> <p>However, this is on another external website so it has to be called with a www or an http:// etc... </p> <p>I am sure it's possible. Just not sure if I should use PHP, DOM or jQuery etc..</p> <p>I am thinking this code should be possible to do in a few lines. Just don't know what is the best method. Thanks for the tips or ideas. </p> <p><strong>UPDATE:</strong> It was suggested this was a duplicate question. It is not. I have used the code from the suggested duplicate question below and it does not work. </p> <p><strong>Here is one of the errors:</strong> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: ID changeRegionForm already defined in Entity, line: 85 in /home/content/w/i/s/wisdom33/html/testing/getDivExternalWebsite.php on line 14</p> <p>Here is a link to the code: <a href="http://massmediamail.com/testing/getDivExternalWebsite.php" rel="nofollow">http://massmediamail.com/testing/getDivExternalWebsite.php</a></p> <p>Here is the code:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;? $doc = new DomDocument; // We need to validate our document before refering to the id $doc-&gt;validateOnParse = true; $doc-&gt;loadHtml(file_get_contents('http://www.lifesitenews.com/news/second-madagascar-archbishop-criticizes-catholic-relief-services-full-trans')); var_dump($doc-&gt;getElementById('article-body')); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload