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. . . .
- //You need to call the php package, retrieve and download it from oschina
- include "Snoopy.class.php"; // Capture web page information, support http code method,
- include " simple_html_dom.php"; //html analysis package
- $snoopy = new Snoopy;
- // $snoopy->proxy_host="###";
- // $snoopy->proxy_port="8888";
- / / $snoopy->user="***";
- // $snoopy->pass="&*";
- $snoopy->agent = "(Mozilla/5.0 (Windows NT 6.1; Win64 ; ["oscid"] = '&&';
-
-
- $snoopy->fetch("https://www.oschina.net/home/login?goto_page=http%3A%2F%2Fwww.oschina .net%2F");
-
-
- //Authentication requires authentication to have permission to obtain data
- $submit_url = "http://www.oschina.net/action/user/hash_login";
- $submit_vars["email" ] = "&**";
- $submit_vars["pwd"] = SHA1("&&*");
- $submit_vars["save_login"] = 1;
- $submit_vars["submit"] = "Log in now";
- $snoopy->submit($submit_url,$submit_vars);
- echo "Authentication status n";
-
- // print $snoopy->results;
-
-
- //After the authentication is passed, Start getting data
- $snoopy->fetch("http://my.oschina.net/&&/admin/inbox");
- echo "Open Source China Personal Account Information Test Programn";
- echo " Time: ".date("Y-m-d h:i:s")."n";
- // echo iconv("UTF-8","GBK//IGNORE",$snoopy->results);
- $result =$snoopy->results;
-
- // print $result;
-
- //simple_html_dom explanation package usage example
- $SHTML=new simple_html_dom();
- $html = str_get_html($result);
- $messS=$html ->find('ul.Msgs li[id]');
- foreach($messS as $mess){
- $aT=$SHTML->load($mess);
- echo "====== =============n";
- echo $aT."n";
- echo "-----------nThe following is the analysis and extraction processing of the above html information: n";
- echo 'Message id: '.$aT->find('li[id]',0)->id.''."n";
- echo 'Message: '.trim($aT ->find('div.msg',0)->plaintext)."n";
- echo 'Date: '.trim($aT->find('div.bottom span.date',0) ->plaintext).' '."n";
- print("===================n");
- }
-
-
-
- Copy code
|