Skip to content

Instantly share code, notes, and snippets.

@berlanga2008
Created June 26, 2015 20:05
Show Gist options
  • Save berlanga2008/20a40f5aabcac2910ba5 to your computer and use it in GitHub Desktop.
Save berlanga2008/20a40f5aabcac2910ba5 to your computer and use it in GitHub Desktop.
scrapear 1155.cr
<?php
//header('Content-type: text/plain');
require_once('simple_html_dom.php');
$url ='http://www.1155.cr/racsa-yp/IDA2?IDAERROR=&BCP=&NAM=&BCP=&BCOD=1946&CATCODE=2584&LOC=&UPDATEDLOC=&TEL=&ZCD=&REG=&STN=&STR=&SRT=&XCO=&YCO=&STP=S&LIP=osaSearchResult_subscriberList&LNK=000B003203FF60020001510200010003116F0003118D000314350003BA3D00000000000C534F52543A52414353415F3107BE0000&SOP=nxt&LANG=es&ACTION=simpleSearch&PAGE=osaSearchResult_subscriberList&YSD=29808&TEMP1=&TEMC=novalue&TEMC2=&TEMP=&RNG=&INDEX=&oldprovince=&MDN=Farmacias&ADR=&ATTRIBUTE=&currentURL=&formType=nextpage&previousPageContext=&nextLinkContext=000B003203FF60020001510200010003116F0003118D000314350003BA3D00000000000C534F52543A52414353415F3107BE0000&counter=1&LNKP=000B003203FF6002000154EF00010003116F0003118D000314350003B66500000000000C534F52543A52414353415F3107BE0000';
$html=new simple_html_dom();
$html = file_get_html($url);
$linkObjs = $html->find('#centrolistado-psbronze a');
$items = $html->find('#centrolistado-psbronze');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<?php
echo '<pre>';
echo "-------------------------------------1<br>";
foreach($html->find('#centrolistado-psbronze') as $header) {
$headlines[] = $header->plaintext;
}
print_r($headlines);
$articles = array();
echo "--------------------------------------2<br>";
foreach($html->find('a[class="url"]') as $a) {
$links2[] = $a->href;
}
print_r($links2);
echo "---------------------------------------3<br>";
foreach($html->find('#centrolistado-psbronze script') as $a) {
$links[]= strip_tags($a->innertext);
$name[] = $a->innertext;
}
print_r($name);
echo '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment