Last active
August 29, 2015 14:04
-
-
Save iann0036/a54d546a29e20b4bf0ee to your computer and use it in GitHub Desktop.
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 | |
$page_max = 123; | |
$leadurl = ''; | |
$results = array(); | |
for ($page=1; $page<$page_max; $page++) { | |
$doc = new DOMDocument(); | |
$doc->loadHTML(file_get_contents($leadurl.$page)); | |
$elems = $doc->getElementsByTagName('div'); | |
foreach ($elems as $elem) { | |
$length = $elem->attributes->length; | |
for ($i=0; $i<$length; $i++) { | |
if ($elem->attributes->item($i)->name=="attr-name") { | |
$value = $elem->attributes->item($i)->value; | |
$parts = explode("\n",$elem->textContent); | |
foreach ($parts as $part) { | |
if (strpos($part,"SOMETEXT")!==FALSE) { | |
$attr = filter_var($part, FILTER_SANITIZE_NUMBER_INT); | |
break; | |
} | |
} | |
$results[] = array('value' => $value, 'attr' => $attr); | |
echo $value.','.$attr."<br>"; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment