Guest User

systemscraper.php

a guest
Feb 17th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 KB | None | 0 0
  1. <pre>
  2. <?php
  3. /* If having questions, contact Veetor Nara via evemail or convo. */
  4. /* Save this output to kills.txt (Stripping the array( ) out of it) */
  5. $data = array();
  6.  
  7.  
  8. function extractSystemPage($page = 1) { // paging starts with 1
  9.     $systemlink = "http://zkillboard.com/system/30005297/page/$page/";
  10.     $rawpage = file_get_contents($systemlink);
  11.     $doc = new DOMDocument();
  12.     @$doc->loadHTML($rawpage);
  13.  
  14.     $xpath = new DOMXPath($doc);
  15.     $nodes = $xpath->query("//table/tbody/tr[@class = 'winwin killListRow']");
  16.  
  17.     foreach( $nodes as $node ) {
  18.         walkDom($node);
  19.     }
  20. }
  21.  
  22. for ( $i=1; $i < 23; $i++ ) {
  23.     echo "extracting page #1... ";
  24.     set_time_limit (120);
  25.     sleep(1);
  26.     extractSystemPage($i);
  27. }
  28.  
  29.  
  30. $data = array_unique($data);
  31. print_r($data);
  32.  
  33. function walkDom($node) {
  34.     if ( $node->nodeType == XML_ELEMENT_NODE ) {
  35.         $attributes = $node->attributes; // get all the attributes(eg: id, class)
  36.         foreach($attributes as $attribute) {
  37.             //echo ', '.$attribute->name.'='.trim($attribute->value);
  38.             if ($attribute->name == "href") { //  /kill/id/
  39.                 $arr = explode("/",$attribute->value);
  40.                 if ($arr[1] == "kill") {
  41.                     // Kills are between the event
  42.                     if ($arr[2] <= "44615772" && $arr[2] >= "44581979") {
  43.                         addKillID($arr[2]);
  44.                     }
  45.                 }
  46.             }
  47.         }                                                    
  48.     }
  49.  
  50.     $cNodes = $node->childNodes;
  51.     if (count($cNodes) > 0) {
  52.         foreach($cNodes as $cNode)
  53.             walkDom($cNode);
  54.     }
  55. }
  56.  
  57. function addKillID($id) {
  58.     global $data;
  59.     $data[] = $id;
  60. }
  61. ?></pre>
Advertisement
Add Comment
Please, Sign In to add comment