I am webscraping a website and I am having difficulty with one item.
$coprp = split_string($coprp, "<td id=\"p\" class=\"datatable-item\">",AFTER,EXCL);
$coprp = split_string($coprp, "td id=\"nch\"", BEFORE, EXCL);
$coprp = strip_tags($coprp);
$coprp = trim($coprp);
$coprp= str_split($coprp,100);
$commd[2] = $coprp[0];
the target line is:
td id="p" class="datatable-item" style="background-color: rgb(255, 255, 255);">3.7624</td
The problem is I can get the 3.7624 and display it but I can not put it into an array for numbers because it has this style elementattached that is unseen in the regular html.
Is there a simple direct way to remove this unseen line using PHP?
If I understand your question correctly, your tag should be:
In PHP, to get the data from a td tag, you can use DOMDocument
This is a working code:
On execution you will be
3.7624(without style element)