Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function get_contents($url) {
- // We could just use file_get_contents but using curl makes it more future-proof (setting a timeout for example)
- $ch = curl_init($url);
- curl_setopt_array($ch, array(CURLOPT_RETURNTRANSFER => true,));
- $content = curl_exec($ch);
- curl_close($ch);
- return $content;
- }
- function scrape_main_page() {
- set_time_limit(300);
- libxml_use_internal_errors(true); // Prevent DOMDocument from spraying errors onto the page and hide those errors internally ;)
- $html = get_contents("http://lmvz.anofm.ro:8080/lmv/index2.jsp?judet=26");
- $dom = new DOMDocument();
- $dom->loadHTML($html);
- $xpath = new DOMXPath($dom);
- $results = $xpath->query("//table[@width=\"645\"]/tr");
- $all = array();
- //var_dump($results);
- for ($i = 1; $i < $results->length; $i++) {
- $tr = $results->item($i);
- $id = $tr->childNodes->item(0)->textContent;
- $requesturl = "http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=".urlencode($id)."&judet=26";
- $details = scrape_detail_page($requesturl);
- $newObj = new stdClass();
- $newObj = $id;
- $all[] = $newObj;
- }
- foreach ($all as $xtr){
- $urls[] = "http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=".$xtr."&judet=26";
- }
- return $urls;
- }
- function scrape_detail_page($url) {
- }
- scrape_main_page();
Advertisement
Add Comment
Please, Sign In to add comment