Search code examples
phpfor-loopscraperscraperwiki

Foreach loop dieing after one iteration


I've been experimenting with ScraperWiki and yesterday, I could get a list of all lis in the DOM. Now, however, I only run through one iteration.

This is my code

$html = 'www.blah...'
$dom = new simple_html_dom();
$dom->load($html);
print_r('Starting parse');
$events = $dom->find("ul.listing li");
print_r('Found '.count($events).' events'); // shows there are 26 nodes
foreach($events as $data){
 // perform some processing then print to the console

I'm not really a PHP guy so I may be missing something obvious. The full source is at https://scraperwiki.com/scrapers/days_of_the_year/


Solution

  • How very clumsy of me. I was missing the fact that the output was truncated after one line in the console. I added a linebreak and now get the expected output.