Batch download Sogou Dictionary-PHP source code

Source: Internet
Author: User
Batch download Sogou Dictionary Batch download, Sogou Dictionary

 "; Echo urlencode (iconv (" UTF-8 "," GB2312 // IGNORE "," China "); echo urlencode ("/"); require_once" pinyin. php "; $ pinyin = new PY_deal (); echo join ($ pinyin-> pinyin (" wheat bags wholesale, [Charm/Twilight swaying/youthful secret] Three types of style, free to choose! Now you only need 50 RMB/fee! "); */$ Fp = fopen (" dictory.txt "," a + "); for ($ I = 1; $ I <= 4; $ I ++) {$ curl = curl_init (); $ url = "http://pinyin.sogou.com/dict/search.php? Word = % B0 % A2 % C0 % EF % B0 % CD % B0 % CD % B2 % FA % C6 % B7 % B4 % CA % BB % E3 & type = 0 & personal = 1 & page = {$ I }"; $ options = array (CURLOPT_URL = >$ url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false); curl_setopt_array ($ curl, $ options); $ rs = curl_exec ($ curl ); curl_close ($ curl); $ pattern_list = "/\
 
  
([\ S \ s] + )? \ <\/Dl \>/I "; preg_match_all ($ pattern_list, $ rs, $ match); $ rs = $ match [1] [0]; $ pattern = "/\? Id = (\ d + ?) \ "/I"; preg_match_all ($ pattern, $ rs, $ match); $ rs = $ match [1]; foreach ($ rs as $ v) {$ link = "http://pinyin.sogou.com/dict/download_txt.php? Id = {$ v} "; $ curl = curl_init (); $ options = array (CURLOPT_URL => $ link, CURLOPT_FILE => $ fp, CURLOPT_HEADER => false ); curl_setopt_array ($ curl, $ options); curl_exec ($ curl); curl_close ($ curl) ;}} fclose ($ fp);?>
 

2.PHP code
$fp=fopen("dictory.txt", "a+");    for($i=1;$i<=4;$i++){        $curl=curl_init();        $url="http://pinyin.sogou.com/dict/search.php?        word=%B0%A2%C0%EF%B0%CD%B0%CD%B2%FA%C6%B7%B4%CA%BB%E3&type=0&personal=1&page={$i}";        $options=array(CURLOPT_URL=>$url,CURLOPT_RETURNTRANSFER=>true,CURLOPT_HEADER=>false);        curl_setopt_array($curl, $options);        $rs=curl_exec($curl);        curl_close($curl);        $pattern_list="/\
 
  ([\S\s]+)?\<\/dl\>/i";        preg_match_all($pattern_list,$rs,$match);        $rs=$match[1][0];        $pattern="/\?id=(\d+?)\"/i";        preg_match_all($pattern,$rs,$match);        $rs=$match[1];                 foreach($rs as $v){            $link="http://pinyin.sogou.com/dict/download_txt.php?id={$v}";            $curl=curl_init();            $options=array(CURLOPT_URL=>$link,CURLOPT_FILE=>$fp,CURLOPT_HEADER=>false);            curl_setopt_array($curl, $options);            curl_exec($curl);            curl_close($curl);                      }     }          fclose($fp);
 

The above is the content of the Sogou dictionary for batch download. For more information, see The PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.