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
<?php | |
if (isset($_POST['submit'])) { | |
// Empty array for errors | |
$errors = array(); | |
// Name validation | |
if (empty($_POST['name'])) { | |
$errors['name'] = "Debe completar"; | |
} else { |
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
<?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); |
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
<?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); |
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
<?php | |
class yahooScraper { | |
/** | |
* Properties | |
*/ | |
private $html; | |
private $resultsContainer; | |
private $resultsCount; | |
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
<?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/>"; |
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
<?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); |