PHP code example of liaosp / tool
1. Go to this page and download the library: Download liaosp/tool library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
liaosp / tool example snippets
UrlTool::getTopHost('http://test.test.liaosp.crm.dingdong.site',2);
$data = [
['id'=>'1','name'=>'liaosp'],
['id'=>'3','name'=>'liaosp'],
['id'=>'2','name'=>'lianmin'],
];
$obj = new array_index();
$res =$obj::index($data,'name');
var_dump($res);exit;
$obj = new \Liaosp\Tool\Spider\Wechat\WxCrawler();
$data =$obj->crawByUrl('https://mp.weixin.qq.com/s?timestamp=1563437558&src=3&ver=1&signature=FIUv1dgs8cmQWLd3A1OlV5x3Ln5Nmz8b5zOQw9*WuwQdXmJolSxfDZku2UW6-vsiBIA5GfaTS1NR6fEN8*6ubmySiAStgwqQ-vkfYZR9igI6KtgjOEHZPEyNk98nNjaoguA0v0tBkT4z76-ye1cEnzaJuhgYc9WAPVxiw-y32z4=');
echo ($data['content_html']);
//先爬图片到服务器,再输出 或者 可以把图片图片保存在服务器上,替换url,这时你需要继承WxCrawler进行改写contentHandle方法
//爬取之前设置
//$obj->setAntiLeech('fangpa.php?url=');
header('Content-type: image/jpg');
$url = $_GET['url'];
$refer = "http://www.qq.comsss/";
$opt = [
'http'=>[
'header'=>"Referer: " . $refer
]
];
$context = stream_context_create($opt);
$file_contents = file_get_contents($url);
echo $file_contents;