/**
 * finds 1st substring between opening and closing markers
 * @return result 1st substring
 */
function get_first_string($text, $openingMarker, $closingMarker)
{
    $out_ar = returnSubstrings($text, $openingMarker, $closingMarker);
    $out = $out_ar[0];
    return $out;
}
function scrapeHF()
{
    $url = "http://www.hocicosfelices.com.ar/buscados";
    $html_content = scraperWiki::scrape($url);
    $html = str_get_html($html_content);
    $html_div = $html->find("div.entry-content", 0);
    $pet_htmls = returnSubstrings($html_div, '<h3', '<h3');
    if (count($pet_htmls) > 0) {
        array_shift($pet_htmls);
        foreach ($pet_htmls as $pet_html_raw) {
            //print "pet found: ".$pet_html."\n";
            $pet_html_raw = "<h3" . $pet_html_raw;
            $pet_html = str_get_html($pet_html_raw);
            $title = $pet_html->find("h3", 0)->plaintext;
            $more_info = $pet_html->find("p", 0)->plaintext;
            $img_html = $pet_html->find("img", 0)->outertext;
            $pet_data = array();
            $pet_data["Codigo"] = utf8_encode(trim($title));
            $pet_data["Titulo"] = trim($title);
            $pet_data["Mas_info"] = trim($more_info) . "<br>" . $img_html;
            $address = "";
            if (array_key_exists('Calle', $pet_data)) {
                $address = $pet_data["Calle"] . ", ";
            }
            if (array_key_exists('Barrio', $pet_data)) {
                $address .= $pet_data["Barrio"] . ", ";
            }
            $address .= "San Carlos de Bariloche, Río Negro, Argentina";
            $pet_data["Direccion"] = $address;
            $geo_data = geoCode($address);
            //$geo_data=geoCode($more_info);
            //$pet_data["Cat"]=$cat_ext;
            if (array_key_exists('lat', $geo_data)) {
                $pet_data["Lat"] = $geo_data["lat"];
                $pet_data["Lng"] = $geo_data["lng"];
                $pet_data["Direccion_geo"] = $geo_data["formatted_address"];
                createReport($pet_data);
                //scraperwiki::save(array('Codigo'), $pet_data);
            }
        }
    }
}