I'm making Torrent PHP Crawler and I have problem, here's my code:
// ... the cURL codes (they're working) ...
// Contents of the Page
$contents = curl_exec($crawler->curl);
// Find the Title
$pattern = "/<title>(.*?)<\/title>/s";
preg_match($pattern, $contents, $titlematches);
echo "Title - ".$titlematches[1]."<br/>";
// Find the Category
$pattern = "/Тип<\/td><td(?>[^>]+)>((?>[^<]+))<\/td>/s";
preg_match($pattern, $contents, $categorymatches);
echo "Category - ".$categorymatches[1]."<br/>";
The HTML page ("Тип" means Category and "Филми" means Movies):
<title>The Matrix</title>
<!--Some Codes Here--!>
<tr><td>Тип</td><td valign="top" align=left>Филми</td></tr>
<!--Some Codes Here--!>
The Result:
Title - The Matrix
Notice: Undefined offset: 1 in /var/www/spider.php on line 117
It's showing the title but not the category.. why is that?
I've tried to echo $categorymatches[0]
, $categorymatches[2]
, $categorymatches[3]
without any luck.