<?php error_reporting(E_ERROR | E_WARNING | E_PARSE); $url = 'http://api.xxx.com/api.php?v=1&key=13316479731'; //$strr_ai = curl_request($url, array('wenzhang'=>$text )); switch($LabelArray['PageType']) { case 'List'://处理列表页,只能处理html //$LabelArray['Html']='id="post_list"><a href="http://api-8.xxx.com/2310113.html">测试的网址的</a><id="pager_block">'; break; case 'Pages'://处理多页,只能处理html //$LabelArray['Html']=str_replace('入园时间:</span>','入园时间:</span>插件添加在多页时间前:',$LabelArray['Html']); break; case 'Content'://处理默认页,只能处理html //$LabelArray['Html']=str_replace('<title>','<title>默认页给标题加个前缀:',$LabelArray['Html']).'aaaaaaaaaaaaaaaaaaaaaaaaa'; break; case 'Save'://只有保存时是可以处理标签值的 isset($LabelArray['作者']) && $LabelArray['作者'].=' 保存时您可以修改任意标签的值'; //$LabelArray['内容'] = strip_tags($LabelArray['内容'], '<p><strong><img><br>'); // 保存原文 $src_contents = $LabelArray['内容']; // 去除HTML标签的属性 $LabelArray['内容'] = clean_contents($LabelArray['内容']); //$LabelArray['内容'] = curl_request($url, array('wenzhang'=>$LabelArray['内容'] )); $temp = curl_request($url, array('wenzhang'=>$LabelArray['标题'].' [0x1555] '.PHP_EOL.$LabelArray['内容'] )); //$temp2 = $temp; $temp = str_replace('[0x1555] ', '[0x1555]', $temp); $temp = str_replace(' [0x1555]', '[0x1555]', $temp); $temp = str_replace('[0x1555]'.PHP_EOL, '[0x1555]', $temp); $temp = str_replace('[0x1555]'." ", '[0x1555]', $temp); $temp = explode('[0x1555]', $temp); $LabelArray['内容']=$temp[1]; $LabelArray['标题']=$temp[0]; // 返回结果处理 if (strpos($LabelArray['内容'], 'connect to host') !== false) { $LabelArray['内容'] = $src_contents; } break; default: //$LabelArray['内容']=curl_request($url, array('wenzhang'=>$LabelArray['内容'] )); } echo serialize($LabelArray); function clean_contents($contents) { // $str = preg_replace('#<([^>s/]+)[^>]*>#','<$1>', $contents); // return $str; $sa = new cleanHtml; $sa->allow = array( 'src' ); $sa->exceptions = array( 'img' => array( 'src', 'alt' ), //'a' => array( 'href', 'title' ), 'iframe'=>array('src','frameborder'), ); $str = $sa->strip( $contents ); return $str; } //参数1:访问的URL,参数2:post数据(不填则为GET),参数3:提交的$cookies,参数4:是否返回$cookies function curl_request($url,$post='',$cookie='', $returnCookie=0){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)'); if (ini_get('open_basedir') == '' && strtolower(ini_get('safe_mode')) != 'on'){ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); } curl_setopt($curl, CURLOPT_AUTOREFERER, 1); curl_setopt($curl, CURLOPT_REFERER, "http://XXX"); if($post) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); } if($cookie) { curl_setopt($curl, CURLOPT_COOKIE, $cookie); } curl_setopt($curl, CURLOPT_HEADER, $returnCookie); curl_setopt($curl, CURLOPT_TIMEOUT, 50); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($curl); if (curl_errno($curl)) { return curl_error($curl); } curl_close($curl); if($returnCookie){ list($header, $body) = explode(" ", $data, 2); preg_match_all("/Set-Cookie:([^;]*);/", $header, $matches); $info['cookie'] = substr($matches[1][0], 1); $info['content'] = $body; return $info; }else{ return $data; } } //echo $tag; // 计算中文字符串长度 function utf8_strlen($string = null) { // 将字符串分解为单元 preg_match_all("/./us", $string, $match); // 返回单元个数 return count($match[0]); } function reg_escape( $str ) { $conversions = array( "^" => "^", "[" => "[", "." => ".", "$" => "$", "{" => "{", "*" => "*", "(" => "(", "\" => "\\", "/" => "/", "+" => "+", ")" => ")", "|" => "|", "?" => "?", "<" => "<", ">" => ">" ); return strtr( $str, $conversions ); } /** * Strip attribute Class * Remove attributes from XML elements * @author David (semlabs.co.uk) * @version 0.2.1 */ class cleanHtml{ public $str = ''; public $allow = array(); public $exceptions = array(); public $ignore = array(); public function strip( $str ) { $this->str = $str; if( is_string( $str ) && strlen( $str ) > 0 ) { $res = $this->findElements(); if( is_string( $res ) ) return $res; $nodes = $this->findAttributes( $res ); $this->removeAttributes( $nodes ); } return $this->str; } private function findElements() { # Create an array of elements with attributes $nodes = array(); preg_match_all( "/<([^ !/> ]+)([^>]*)>/i", $this->str, $elements ); foreach( $elements[1] as $el_key => $element ) { if( $elements[2][$el_key] ) { $literal = $elements[0][$el_key]; $element_name = $elements[1][$el_key]; $attributes = $elements[2][$el_key]; if( is_array( $this->ignore ) && !in_array( $element_name, $this->ignore ) ) $nodes[] = array( 'literal' => $literal, 'name' => $element_name, 'attributes' => $attributes ); } } # Return the XML if there were no attributes to remove if( !$nodes[0] ) return $this->str; else return $nodes; } private function findAttributes( $nodes ) { # Extract attributes foreach( $nodes as &$node ) { preg_match_all( "/([^ =]+)s*=s*["|']{0,1}([^"']*)["|']{0,1}/i", $node['attributes'], $attributes ); if( $attributes[1] ) { foreach( $attributes[1] as $att_key => $att ) { $literal = $attributes[0][$att_key]; $attribute_name = $attributes[1][$att_key]; $value = $attributes[2][$att_key]; $atts[] = array( 'literal' => $literal, 'name' => $attribute_name, 'value' => $value ); } } else $node['attributes'] = null; $node['attributes'] = $atts; unset( $atts ); } return $nodes; } private function removeAttributes( $nodes ) { # Remove unwanted attributes foreach( $nodes as $node ) { # Check if node has any attributes to be kept $node_name = $node['name']; $new_attributes = ''; if( is_array( $node['attributes'] ) ) { foreach( $node['attributes'] as $attribute ) { if( ( is_array( $this->allow ) && in_array( $attribute['name'], $this->allow ) ) || $this->isException( $node_name, $attribute['name'], $this->exceptions ) ) $new_attributes = $this->createAttributes( $new_attributes, $attribute['name'], $attribute['value'] ); } } $replacement = ( $new_attributes ) ? "<$node_name $new_attributes>" : "<$node_name>"; $this->str = preg_replace( '/'. reg_escape( $node['literal'] ) .'/', $replacement, $this->str ); } } private function isException( $element_name, $attribute_name, $exceptions ) { if( array_key_exists($element_name, $this->exceptions) ) { if( in_array( $attribute_name, $this->exceptions[$element_name] ) ) return true; } return false; } private function createAttributes( $new_attributes, $name, $value ) { if( $new_attributes ) $new_attributes .= " "; $new_attributes .= "$name="$value""; return $new_attributes; } } ?>
- 1蓝天采集器自动采集不定时停止运行
- 2蓝天采集器自动采集插件在米拓5.3.19下无法采集
- 3蓝天采集器pbootcms文章 (PbootDemoSkycaiji)插件如何设置调用整站目录
- 4蓝天采集器通过 Tor 代理 如何绕过机器人检测
- 5蓝天采集器抓取不了相对地址
- 6蓝天采集器百度知道问题列表页测试抓取获取不到问题列表?
- 7蓝天采集器发布到本地数据库失败
- 8蓝天采集器的数据库账号密码配置文件"data/config.php"
- 9蓝天采集器怎么样采集商品首图
- 10蓝天采集器本地保存excel 出现错误如下
- 11蓝天采集器&的问题
- 12PbootCMS缩略图上传图片变模糊为什么?
- 13蓝天采集器请问一下,能采集JS渲染的内容吗?
- 14化妆品/服装行业网站建设方案
- 15163K网站系统X10_V1升级教程_自动升级系统使用说明
- 16宝塔控制面板如何开启php_fileinfo扩展参数
- 17蓝天采集器为什么我的采集间隔失效了
- 18网站ICP备案需知
- 19狂雨小说CMS-狂雨小说下载-采集规则-导入方法
- 20蓝天采集器采集腾讯企鹅号自媒体内容教程(附采集规则)
-
pbootcms常见的导航高亮下拉标···
我们在做网站的时候经常会遇到一些特殊的导航,比如导航带高亮,二级导航镶嵌下拉等等。当有这些的时候就找不到方法了,默认是无法输出的,今天呢蜀戎网就给大家讲解一下,如何来写这种导航标签。一级栏目调用例子:<ul>{pboot:nav···
-
蓝天采集器求助 发布设置中WordP···
怎么进行数据绑定呢?目录路径应该怎么填?网站是放在根目录下的 你的采集器也是在根目录(或子目录)里吗? 可以直接输入你的网站目录,win主机就输 磁盘:/路径,linux就输/目录 admin 发表于 2018-3-16 21:43 你···
-
百度实名认证接口(人脸身份核验API···
在管理员后台 相亲 基本配置 基本配置 实名认证方式 中 可以设置 实名认证审核方式 其中 身份姓名验证和人像采集验证需要用到百度身份验证(人脸身份核验API) 需要到百···
-
蓝天采集器2.0版本后不能自动采集了
1.3版本还可以自动采集,安装了2.0版本后就不能自动采集了,只能每次保存采集设置才能自动采集一会,然后就没有然后了,无论触发或后台都次保存后就自动采集一会,后面时间都不会自动了。是不是程序漏洞,帮忙看看 你看看网址是不是包含“index···
-
蓝天采集器Z-BlogPHP 1.5···
没搞定,配置好后抓瞎了,不会操作,有搞定的能否分享个,谢谢了