Reputation:
I'm trying to parse this HTML from remote url using Simple HTML DOM Parser:
<div class="_5pbx userContent _3ds9 _3576" data-ft="data-ft='{"tn":"K"}'">
<p>text to be parsed</p>
<p>the rest of text</p>
</div>
The PHP snipe I used is as the following:
include (getdomain . "/lib/simple_html_dom.php");
$html = new simple_html_dom();
$get = file_get_contents("http://localhost/get/d.json");
$html->load($get);
foreach ($html->find('div[class=_5pbx userContent _3ds9 _3576]') as $link) {
if(isset($link)){
echo $link->plaintext ;
}
}
But it didn't work, I'm aware of the <p>
tag and I tried to add if statement for that but still didn't work, as the following:
include (getdomain . "/lib/simple_html_dom.php");
$html = new simple_html_dom();
$get = file_get_contents("http://localhost/get/d.html");
$html->load($get);
foreach ($html->find('div[class=_5pbx userContent _3ds9 _3576]') as $link) {
if(isset($link)){
foreach($link->find('p') as $tag)
{
echo $tag->plaintext ;
}
}
}
But all didn't work :(
Any idea?
Upvotes: 0
Views: 691
Reputation: 174
I tried this. It is working..
<?php
include (getcwd() . "/simple_html_dom.php");
$html = new simple_html_dom();
$get = file_get_contents("http://localhost/zdemo/php%20selenium/d.json");
$html->load($get);
foreach ($html->find('div[class=_5pbx userContent _3ds9 _3576]') as $link)
{
if(isset($link))
{
echo $link->plaintext ;
}
}
Upvotes: 1