SHARE
TWEET

Steam Spider

a guest Aug 14th, 2019 69 in 8 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. require "vendor/autoload.php";
  4.  
  5. use PHPHtmlParser\Dom;
  6.  
  7. $ch = curl_init('https://steamcommunity.com/id/wumai');
  8. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  9. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  10. curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  11. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  12. curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  13. curl_setopt($ch, CURLOPT_PROXY, 'socks5://localhost:1080');
  14. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  15.     'Accept: text/html',
  16.     'Accept-Language: zh-CN'
  17. ));
  18. $html = curl_exec($ch);
  19.  
  20. $html = str_replace('&nbsp;', ' ', $html);
  21.  
  22. $dom = new Dom;
  23. $dom->load($html);
  24.  
  25. $name = $dom->find('.actual_persona_name');
  26. echo "昵称: " . trim($name[0]->text);
  27.  
  28. echo PHP_EOL;
  29.  
  30. $lv = $dom->find('.friendPlayerLevelNum');
  31. echo "等级: " . trim($lv[0]->text);
  32.  
  33. echo PHP_EOL;
  34.  
  35. $status_header = $dom->find('.profile_in_game_header');
  36. echo trim($status_header[0]->text);
  37.  
  38. echo PHP_EOL;
  39.  
  40. $status_header = $dom->find('.profile_in_game_name');
  41. echo trim($status_header[0]->text);
  42.  
  43. echo PHP_EOL;
  44.  
  45. echo '地区: ';
  46. $country = $dom->find('.header_real_name');
  47. if (isset($country[0])) echo trim($country[0]->text);
  48. else echo '未知';
  49.  
  50. echo PHP_EOL;
  51.  
  52. echo '真名: ';
  53. $real_name = $dom->find('bdi');
  54. if (!empty(trim($real_name[0]->text))) echo trim($real_name[0]->text);
  55. else echo "未填写";
  56.  
  57. echo PHP_EOL;
  58.  
  59. echo '封禁: ';
  60. $ban_count = $dom->find('.profile_ban');
  61. $ban_since = $dom->find('.profile_ban_status');
  62. if (isset($ban_count[0])) echo trim($ban_count[0]->text) . ', ' . trim($ban_since[0]->text);
  63. else echo "无";
  64.  
  65. echo PHP_EOL;
  66.  
  67. $counts = $dom->find('.profile_count_link');
  68. if (count($counts) > 0) {
  69.     foreach ($counts as $count) {
  70.         $label = $count->find('.count_link_label');
  71.         if (!isset($label[0])) continue;
  72.         $label = trim($label[0]->text);
  73.  
  74.         $c = $count->find('.profile_count_link_total');
  75.         if (!isset($c[0])) continue;
  76.         $c = trim($c[0]->text);
  77.         if (empty($c)) continue;
  78.  
  79.         echo "$label: $c\r\n";
  80.     }
  81. }
  82.  
  83. echo PHP_EOL;
  84.  
  85. echo "最近游戏: ";
  86. $recent_games = $dom->find('.recent_game_content');
  87. if (isset($recent_games[0])) {
  88.     echo "\r\n";
  89.     foreach ($recent_games as $game) {
  90.         $game = $game->find('.whiteLink')[0];
  91.         echo $game->text . ' (' . $game->getAttribute('href') . ")\r\n";
  92.     }
  93. } else echo "无";
  94.  
  95. echo PHP_EOL;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top