Here's me function with regexp:
preg_match_all('|<span class=\"Menu1\">(.*?)</td>|U',$contents,$wynik2);
It works with:
<tr>
<td width="30%" ><span class="Menu"> Nazwa zawdsdu: </td>
<td width="70%"> <span class="Menu1">PRACOWNIK BARU </td>
</tr>
but it doesn't work with:
<td width="70%"> <span class="Menu1">PRACA W MC DONALDS PRACE PORZĄDKOWE, PRZYJĘCIE DOSTAWY
WYMAGANA KSIĄŻECZKA SANEPIDOWSKA, CHĘCI DO PRACY
KONTAKT TEL. 794295401 </td>
I've got empty array. I think its caused by 'new line'. How can i fix it?
Add the s
modifier to the end of your regex.
Sorry, but I felt obliged to give a DOMDocument example:
$d = new DOMDocument;
$d->loadHTML($html);
$xpath = new DOMXPath($d);
foreach ($xpath->query('//span[@class="Menu1"]') as $node) {
echo $node->nodeValue, PHP_EOL;
}
Applied to your scraper (redacted the url and post fields)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://redacted');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'redacted');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$d = new DOMDocument;
libxml_use_internal_errors(true);
$d->loadHTML(curl_exec($ch));
libxml_clear_errors();
$xpath = new DOMXPath($d);
foreach ($xpath->query('//span[@class="Menu1"]') as $node) {
echo $node->nodeValue, PHP_EOL;
}