Home >Backend Development >PHP Tutorial >程序思路和相关代码

程序思路和相关代码

WBOY
WBOYOriginal
2016-06-13 10:01:10747browse

求一个程序思路和相关代码
我想弄一个这样的网站功能,如http://www.ccua.com.cn/
请教这个站长,可惜他一点也不肯透漏
我暂时没有思路,可否有高手赐教一二?

------解决方案--------------------
通过curl采集内容

本来通过file_get_contents($url)实现采集的。无奈,出了个编码故障始终无法解决。最终选择curl实现。用curl需要将php下的libeay32.dll 和 ssleay32.dll 两个文件copy到 system32 下,然后,将php.ini中的extension = php_curl.dll开启。

代码示例如下。

PHP code
function generateHtmlByCURL($url,$filename)    {    $ch = curl_init();    $timeout = 1000; // set to 0 for no timeout    curl_setopt ($ch, CURLOPT_URL,$url);    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout);    $handles = curl_exec($ch);    curl_close($ch);     file_put_contents ($filename, $handles);   }<div class="clear">
                 
              
              
        
            </div>
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