I have the html document in a php $content
. I can echo it, but I just need all the <a...>
tags with class="pret"
and after I get them I would need the non words (like a code i.e. d3852) from href attribute of <a>
and the number (i.e. 2352.2345) from between <a>
and </a>
.
I have tried more examples from the www but I either get empty arrays or php errors.
A regex example that gives me an empty array (the <a>
tag is in a table)
$pattern = "#<table\s.*?>.*?<a\s.*?class=[\"']pret[\"'].*?>(.*?)</a>.*?</table>#i";
preg_match_all($pattern, $content, $results);
print_r($results[1]);
Another example that gives just an error
$a=$content->getElementsByTagName(a);
Reason for various errors: unvalid html, non utf 8 chars.
Next I did this on another website, matched the contents in a single SQL table, and the result is a copied website with updated data from my country. No longer will I search the www for matching single results.