Skip to content

Instantly share code, notes, and snippets.

@homleen
Created June 5, 2013 08:44
Show Gist options
  • Save homleen/5712537 to your computer and use it in GitHub Desktop.
Save homleen/5712537 to your computer and use it in GitHub Desktop.
pinyin.cn 数据抓取
<?php
set_time_limit(0);
$url =
'http://cn.bing.com/search?q=site%3apinyin.cn&qs=n&pq=site%3apinyin.cn&sc=0-4&sp=-1&sk=&first={ddddd}1&FORM=PERE';
$i = $_GET['i'];
$api = file_get_contents(str_replace('{ddddd}', $i, $url));
preg_match_all('/<a href=\"http:\/\/pinyin.cn\/([a-zA-Z0-9]+)?\"/', $api, $a);
foreach ($a[1] as $v) {
$api = file_get_contents('http://pinyin.cn/' . $v);
preg_match('/<a target="_blank" href="(.*?)">/', $api, $aa);
if ($aa) {
echo '<br>';
echo '<a target="_blank" href="http://pinyin.cn/' . $v . '">http://pinyin.cn/' . $v . '</a>:';
echo
'<img class=\'round_img\' id=\'round_img\' src="' .
$aa[1] .
'" border=0 max-width="210px" max-height="210px" />';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment