Skip to content

Instantly share code, notes, and snippets.

<?php
if (isset($_POST['submit'])) {
// Empty array for errors
$errors = array();
// Name validation
if (empty($_POST['name'])) {
$errors['name'] = "Debe completar";
} else {
<?php
// Html
$html = file_get_contents('https://es.search.yahoo.com/search?p=madrid&fr=yfp-t-777');
// Creating instance of DOMDocument and loading the HTML
$dom = new DOMDocument;
libxml_use_internal_errors(TRUE);
$dom->loadHTML($html);
libxml_use_internal_errors(FALSE);
<?php
// Require de Simple HTML DOM Library
require 'simple_html_dom.php';
// Get HTML from the URL by using a method from the library
$html = file_get_html('https://es.search.yahoo.com/search?p=madrid&fr=yfp-t-777');
// Get the corresponding div with the search results
$div = $html->find('div[id=web]', 0);
<?php
class yahooScraper {
/**
* Properties
*/
private $html;
private $resultsContainer;
private $resultsCount;
<?php
$html = file_get_contents('https://es.search.yahoo.com/search?p=madrid&fr=yfp-t-777');
preg_match('/\<ol class\=\" reg searchCenterMiddle\">(.*?)\<\/ol\>/i', $html, $list);
preg_match_all('/\<li(.*?)\<\/li\>/i', $list[1], $results);
foreach ($results[0] as $result) {
echo strip_tags($result);
echo "<br/>";
<?php
$url = 'https://es.search.yahoo.com/search?p=madrid&fr=yfp-t-777';
$html = file_get_contents($url);
$dom = new DOMDocument;
libxml_use_internal_errors(TRUE);
$dom->loadHTML($html);
libxml_use_internal_errors(FALSE);