Hi Guys,
I really hope one of you clever genious's can help me. Below is a code which I derived myself, it basically opens up the amazon website on to the page, scrapes everything in between the body tags and then it's supposed to filter out everything into <p></p> tags. But I'm getting the following error 😕
Warning: Invalid argument supplied for foreach() in /var/www/vhosts/...scrapeamazon.php on line 13
<?php
$bbc = "http://www.amazon.co.uk/";
preg_match_all('/<body[^>]*>\s*(.*?)\s*<\/body>/is',file_get_contents($bbc), $bbcwebsite);
$bodytags = $bbcwebsite[1];
if(empty($bodytags) || $bodytags == NULL) {
$bbcbody = "Nothing here 1!"; } else {
foreach ($bodytags as $line_num => $link) {
$bbcbody = $link . "<br />\n";
preg_match_all('/<p[^>]*>\s*(.*?)\s*<\/p>/is', $bbcbody, $bbcp);
$pcontent = $bbcp[1] . "<br />\n";
if(empty($pcontent) || $pcontent == NULL) {
$bbcptag = "Nothing here 2!"; } else {
foreach ($pcontent as $line_num => $ptag) {
$bbcptag .= $ptag . "<br />\n";
}
}
}
}
?>
I would really appreciate someone's help and thank you in advance. 🙂
M