Skip to content

Commit

Permalink
Update scraper.php
Browse files Browse the repository at this point in the history
  • Loading branch information
vikash12345 committed Jan 23, 2018
1 parent 86e1965 commit 224c437
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions scraper.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
<?
// This is a template for a PHP scraper on morph.io (https://morph.io)
// including some code snippets below that you should find helpful

// require 'scraperwiki.php';
// require 'scraperwiki/simple_html_dom.php';
//
// // Read in a page
// $html = scraperwiki::scrape("http://foo.com");
//
// // Find something on the page using css selectors
// $dom = new simple_html_dom();
// $dom->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".
require 'scraperwiki.php';
require 'scraperwiki/simple_html_dom.php';
for($page = 1; $page < 500 ; $page++)
{
$BaseLink = 'http://sipp.pn-watansoppeng.go.id/list_perkara/page/'.$page;
$Html = file_get_html($BaseLink);
$RowNumb = -1;

if ($Html)
{
// Paginate all 'View' buttons
foreach ($Html->find("//*[@id='tablePerkaraAll']/tbody/tr") as $element)
{
$RowNumb += 1;

if ($RowNumb != 0)
{
$no = $element->find('td[1]', 0)->plaintext;
$nomor = $element->find('td[2]', 0)->plaintext;
$tangal = $element->find('td[3]', 0)->plaintext;
$klasifikasi = $element->find('td[4]', 0)->plaintext;
$para = $element->find('td[5]', 0)->plaintext;
$status = $element->find('td[6]', 0)->plaintext;
$lama = $element->find('td[7]', 0)->plaintext;
$details = $element->find('td[8]\a', 0)->href;

$record = array( 'num' => $no, 'nomor' => $nomor, 'tangal' => $tangal, 'klasifikasi' => $klasifikasi, 'para' => $para, 'status' => $status, 'lama' => $lama, 'details' => $details, 'pagelink' => $BaseLink);
scraperwiki::save(array('num','nomor','tangal','klasifikasi','para','status','lama','details','pagelink'), $record);


}
}
}
}


?>

0 comments on commit 224c437

Please sign in to comment.