Home >Backend Development >PHP Tutorial >Open source Chinese personal account information capture example

Open source Chinese personal account information capture example

WBOY
WBOYOriginal
2016-07-25 08:49:13828browse
Open source Chinese personal account information capture example, the code is for reference, simple improvement, you can quickly create a command line tool to manage your own account.
The example uses snoopy, simple_html_dom package, which can be downloaded directly from open source China. . . .

Open source Chinese personal account information capture example Open source Chinese personal account information capture example Open source Chinese personal account information capture example Open source Chinese personal account information capture example Open source Chinese personal account information capture example
  1. //You need to call the php package, retrieve and download it from oschina
  2. include "Snoopy.class.php"; // Capture web page information, support http code method,
  3. include " simple_html_dom.php"; //html analysis package
  4. $snoopy = new Snoopy;
  5. // $snoopy->proxy_host="###";
  6. // $snoopy->proxy_port="8888";
  7. / / $snoopy->user="***";
  8. // $snoopy->pass="&*";
  9. $snoopy->agent = "(Mozilla/5.0 (Windows NT 6.1; Win64 ; ["oscid"] = '&&';
  10. $snoopy->fetch("https://www.oschina.net/home/login?goto_page=http%3A%2F%2Fwww.oschina .net%2F");
  11. //Authentication requires authentication to have permission to obtain data
  12. $submit_url = "http://www.oschina.net/action/user/hash_login";
  13. $submit_vars["email" ] = "&**";
  14. $submit_vars["pwd"] = SHA1("&&*");
  15. $submit_vars["save_login"] = 1;
  16. $submit_vars["submit"] = "Log in now";
  17. $snoopy->submit($submit_url,$submit_vars);
  18. echo "Authentication status n";
  19. // print $snoopy->results;
  20. //After the authentication is passed, Start getting data
  21. $snoopy->fetch("http://my.oschina.net/&&/admin/inbox");
  22. echo "Open Source China Personal Account Information Test Programn";
  23. echo " Time: ".date("Y-m-d h:i:s")."n";
  24. // echo iconv("UTF-8","GBK//IGNORE",$snoopy->results);
  25. $result =$snoopy->results;
  26. // print $result;
  27. //simple_html_dom explanation package usage example
  28. $SHTML=new simple_html_dom();
  29. $html = str_get_html($result);
  30. $messS=$html ->find('ul.Msgs li[id]');
  31. foreach($messS as $mess){
  32. $aT=$SHTML->load($mess);
  33. echo "====== =============n";
  34. echo $aT."n";
  35. echo "-----------nThe following is the analysis and extraction processing of the above html information: n";
  36. echo 'Message id: '.$aT->find('li[id]',0)->id.''."n";
  37. echo 'Message: '.trim($aT ->find('div.msg',0)->plaintext)."n";
  38. echo 'Date: '.trim($aT->find('div.bottom span.date',0) ->plaintext).' '."n";
  39. print("===================n");
  40. }
  41. Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn