File "example_scraping_general.php"

Full path: /home/kosmetik/public_html/api/price_hunt/example/scraping/example_scraping_general.php
File size: 1.06 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

include_once 'simple_html_dom.php';
function scraping_generic($url, $search)
{
    $return = false;
    echo "reading the url: " . $url . "<br/>";
    $html = file_get_html($url);
    echo "url has been read.<br/>";
    foreach ($html->find($search) as $found) {
        $return - true;
        echo "found a: " . $search . "<br/><pre>";
        $found->dump();
        echo "</pre><br/>";
    }
    $html->clear();
    unset($html);
    return $return;
}
error_log("post:" . print_r($_POST, true));
$url = "";
if (isset($_POST['url'])) {
    $url = $_POST['url'];
}
$search = "";
if (isset($_POST['search'])) {
    $search = $_POST['search'];
}
?>
<form method="post">
	URL: <input name="url" type="text" value="<?php 
echo $url;
?>"/><br/>
	Search: <input name="search" type="text" value="<?php 
echo $search;
?>"/>
	<input name="submit" type="submit" value="Submit"/>
</form>
<?php 
if (isset($_POST['submit'])) {
    $response = scraping_generic($_POST['url'], $_POST['search']);
    if (!$response) {
        echo "Did not find any: " . $_POST['search'] . "<br />";
    }
}