[Help] PHP collection page information need to collect & nbsp; http://bbs.zhanzhang.baidu.com/home.php? Mod = space & amp; uid = * the user names of different UIDs are not familiar with PHP and regular expressions, but they only want results. Therefore, you need to directly give the PHP code and the user names of the first 1000 UIDs, thank you. [Help] PHP collects webpage information
Need to collect
Http://bbs.zhanzhang.baidu.com/home.php? Mod = space & uid = *
User names with different UIDs
I'm not familiar with PHP and regular expressions. I just want to get the results. so I have to give the PHP code and the first 1000 UID usernames directly. thank you. Php
------ Solution --------------------
$html = file_get_contents('http://bbs.zhanzhang.baidu.com/home.php?mod=space&uid=1');
preg_match('@(.*?)<\/h2>@',$html,$match);
//var_dump($match);
echo strip_tags($match[0]);
In theory, uid is auto-incrementing. The first 1000 are 1-1000. change the number yourself.
------ Solution --------------------
$ Url = 'http: // bbs.zhanzhang.baidu.com/home.php? Mod = space & uid = ';
$ Res = array ();
$ Uid = 1;
While (count ($ res) <20) {// obtain the first 20 items and modify them as needed
If (preg_match ('// s', file_get_contents ($ url. $ uid), $ r )){
If (preg_match_all ('/\ w +/', strip_tags ($ r [0]), $ r) = 3 ){
$ Res [$ r [0] [2] = $ r [0] [0];
}
}
$ Uid ++;
}
Print_r ($ res );
Result: (the join key is UID and the value is the user name)
Array
(
[1] => sitemapbbs
[7] => _
[8] => sitemapTest2
[9] => sitemapTest
[10] => sitemapTest32
[13] => sitemapTest3
[14] => kkkksuper
[16] => 05
[17] => caoli456
[18] => wangbin_ivan
[19] => geiwosou
[20] => sitemap_test1
[21] => sitemap_test5
[22] => _
[23] => lkmmmmj
[24] => blackfox1983
[25] => dongbei_wb
[26] => xyzlinger
[27] => sanwushuosi
[28] => 007
)
------ Solution --------------------
Same as above, but the file_get_contents method is sometimes too slow and curl can be used.