diff --git a/scraper.php b/scraper.php index 87fec18..d97ef62 100644 --- a/scraper.php +++ b/scraper.php @@ -1,27 +1,33 @@ -load($html); -// print_r($dom->find("table.list")); -// -// // Write out to the sqlite database using scraperwiki library -// scraperwiki::save_sqlite(array('name'), array('name' => 'susan', 'occupation' => 'software developer')); -// -// // An arbitrary query against the database -// scraperwiki::select("* from data where 'name'='peter'") - -// You don't have to do things with the ScraperWiki library. -// You can use whatever libraries you want: https://morph.io/documentation/php -// All that matters is that your final data is written to an SQLite database -// called "data.sqlite" in the current working directory which has at least a table -// called "data". +(.*?)\..*?.*? \.*?\).*?|',$html,$arr); + + foreach ($arr[1] as $key=>$val) { + scraperwiki::save(array('rank'), array('rank' => "".clean($arr[1][$key]),'imdb_id' => clean($arr[2][$key]))); + } + function clean($val) { + $val = str_replace(' ',' ',$val); + $val = str_replace('&','&',$val); + $val = html_entity_decode($val); + $val = strip_tags($val); + $val = trim($val); + $val = utf8_decode($val); + return($val); + } + + function oneline($code) { + $code = str_replace("\n",'',$code); + $code = str_replace("\r",'',$code); + return $code; + } ?>