I am parsing my website (html code) with curl:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com/product.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$content = curl_exec($ch);
Now i want to find a specific <span>
with an <a>
the a tag contains an href
with a parameter. Is it possible to find this parameter ([eventUid]=22
) with preg match? I want to save the 22
(id) that comes from a database to a variable using PHP.
Example:
<span><a title="mytitle" href="http://example.com/products.html?tx_example_pi1[eventUid]=22">example</a></span>
if (preg_match('@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@', $content, $matches)) {
echo $matches[2];
} else {
echo 'Nothing found!';
}
At the moment I only found links with this preg search.