Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c839fd
commit 1e5048b
Showing
1 changed file
with
20 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,21 @@ | ||
<? | ||
// 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'; | ||
|
||
$counter = 0; | ||
$html = scraperwiki::scrape('https://www.olx.com.pk/cars/'); | ||
$dom = new simple_html_dom(); | ||
$dom->load($html); | ||
|
||
$title = $dom->find("h3.large"); | ||
if(!empty($title)){ | ||
$counter; | ||
} | ||
echo $counter; | ||
|
||
|
||
|
||
|
||
|
||
?> |