protected function execute(InputInterface $input, OutputInterface $output)
 {
     $default_url = "http://www.sainsburys.co.uk/webapp/wcs/stores/servlet/CategoryDisplay?listView=true&orderBy=FAVOURITES_FIRST&parent_category_rn=12518&top_category=12518&langId=44&beginIndex=0&pageSize=20&catalogId=10137&searchTerm=&categoryId=185749&listId=&storeId=10151&promotionId=#langId=44&storeId=10151&catalogId=10137&categoryId=185749&parent_category_rn=12518&top_category=12518&pageSize=20&orderBy=FAVOURITES_FIRST&searchTerm=&beginIndex=0&hideFilters=true";
     $scraper = new Scraper($default_url);
     $scraped_products = $scraper->scrape();
     if ($input->getOption('prettyprint')) {
         $pretty_print = True;
     } else {
         $pretty_print = False;
     }
     $json = $scraper->construct_json($scraped_products, $pretty = $pretty_print);
     $output->writeln($json);
 }
Esempio n. 2
0
<?php

require_once 'vendor/autoload.php';
require_once './classes/Scraper.class.php';
$default_url = "http://www.sainsburys.co.uk/webapp/wcs/stores/servlet/CategoryDisplay?listView=true&orderBy=FAVOURITES_FIRST&parent_category_rn=12518&top_category=12518&langId=44&beginIndex=0&pageSize=20&catalogId=10137&searchTerm=&categoryId=185749&listId=&storeId=10151&promotionId=#langId=44&storeId=10151&catalogId=10137&categoryId=185749&parent_category_rn=12518&top_category=12518&pageSize=20&orderBy=FAVOURITES_FIRST&searchTerm=&beginIndex=0&hideFilters=true";
$scraper = new Scraper($default_url);
$scraped_products = $scraper->scrape();
print_r($scraper->construct_json($scraped_products, $pretty = True));