I am trying to get information using curl.
Approximately I got all information, but I need to get information individually.
For example I am getting a td text using curl.
here is the td content
I need to extract text "my info", myinfo href link and last page number.
How i can do this?
here is my code which i am using in curl
$nodes = $finder->evaluate('//td[contains(text(), "") and starts-with(@id, "td_threadtitle_") ]');
foreach ($nodes as $node)
{
$innerHTML = trim($tmp_dom->saveHTML());
$fh = fopen("test.html", 'w'); // we create the file, notice the 'w'. This is to be able to write to the file once.
//writing response in newly created file
fwrite($fh, $node->c14n()); // here we write the data to the file.
fclose($fh);
}
My info
(//td[starts-with(@id, "td_threadtitle_") ]//a[1]/text())[1]
It's href
(//td[starts-with(@id, "td_threadtitle_") ]//a)[1]/@href
Last page number
substring-after(//td[starts-with(@id, "td_threadtitle_") ]//a[. = "Last Page"]/@href, "page=")
I tried this and it's according to my requirement.
Please tell me is this ok or not?
$options = $node->getElementsByTagName('a');
$post_message_id=$node->getAttribute('id');
foreach($options as $option) {
$value = $option->getAttribute('id');
if($value!=""){
print_r( $option->getAttribute('href'));
echo "
";
print_r( $option->textContent);
echo "
";
print_r($options->item(($options->length)-1)->getAttribute('href'));
echo "
";
}
}