智伍应用 發表於 2022-8-23 12:29:21

【免费开源】利用云数据API接口,开发属于自己的采集器

<br />复制下面的代码,保存为一个php文件即可,可以把代码封装一下,变成自己的东西!<br /><ol><li>&lt;?php<br /><li>header(&quot;Content-type: text/html; charset=utf-8&quot;);<br /><li>function get_sign($dataArr) //计算签名验证的函数<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; if(!is_array($dataArr))<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 'no';<br /><li><br /><li>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br /><li><br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ksort($dataArr, SORT_STRING);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $string1 = '';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach ($dataArr as $k =&gt; $v) {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $v=urlencode($v);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $string1 .= &quot;{$k}={$v}&amp;&quot;;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return strtoupper(md5($string1));<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; }<br /><li>}<br /><li>function get_json_data($dataUrl) // 根据接口地址,转换成具体列表内容,展示结果<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $nowTime=time();<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $tokenStr=file_get_contents('./appid.txt'); // 读取保存的appid和对应的密钥<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $tokenArr=explode('_ZW_',$tokenStr);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $appid=$tokenArr;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $appid_key=$tokenArr;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $dataJson=file_get_contents($dataUrl);&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $dataJson=trim($dataJson);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $dataNewsArr=json_decode($dataJson,true);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result='&lt;hr&gt;&lt;h2&gt;下面是结果内容&lt;/h2&gt;&lt;hr&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;table border=1 cellpadding=12 style=&quot;width:100%;&quot;&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;tr&gt;&lt;th&gt;一键采集&lt;/th&gt;&lt;th&gt;标题&lt;/th&gt;&lt;th&gt;链接地址&lt;/th&gt;&lt;th&gt;发布时间&lt;/th&gt;&lt;/tr&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; foreach($dataNewsArr as $item)<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $signArr=array();<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $signArr['url']=urldecode($item['fromurl']);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $signArr['appid']=$appid;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $signArr['t']=$nowTime;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $signArr['appsecret']=$appid_key; // 密钥仅用于计算签名,不要公开,私密<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sign=get_sign($signArr);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;tr style=&quot;text-align:center&quot;&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;td nowrap&gt;&lt;a href=&quot;./sdk_demo.php?ac=content&amp;url='.urlencode($item['fromurl']).'&amp;appid='.$appid.'&amp;t='.$nowTime.'&amp;sign='.$sign.'&quot;&gt; 点击采集 &lt;/a&gt;&lt;/td&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;td&gt;'.$item['title'].'&lt;/td&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;td&gt;&lt;a href=&quot;'.$item['fromurl'].'&quot; target=&quot;_blank&quot;&gt;'.$item['fromurl'].'&lt;/a&gt;&lt;/td&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;td nowrap&gt;'.date('Y-m-d H:i:s',$item['sendtime']).'&lt;/td&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;/tr&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; }<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=$result.'&lt;/table&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; return $result;<br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='register')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; if(!file_exists('./appid.txt'))<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $appid=php_uname('s').php_uname('n').php_uname('m'); // 根据服务器的特征,生成唯一appid,请求获得密钥之后,保存到本地<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $appid=$appid.__DIR__;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $appid=md5($appid);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $appid_key=file_get_contents(&quot;http://api.zhiwu55.net/v1/catch_data/register/?appid=&quot;.$appid);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $dataStr=$appid.'_ZW_'.$appid_key;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; file_put_contents('./appid.txt',$dataStr); //生产环境中,上线了,千万不要这样保存appid和密钥,相当于公开暴露出去了<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; }<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result='&lt;hr&gt;&lt;h2&gt;下面是结果内容&lt;/h2&gt;&lt;hr&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;注册appid成功!已经保存到appid.txt文件中';&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='content')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $fromurl=urlencode($_GET['url']);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $dataUrl=&quot;http://api.zhiwu55.net/v1/catch_data/content/?url={$fromurl}&amp;appid={$_GET['appid']}&amp;t={$_GET['t']}&amp;sign={$_GET['sign']}&quot;;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $content=file_get_contents($dataUrl);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; if($content=='Requests are too frequent')<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result='&lt;h1&gt;采集过于频繁!&lt;/h1&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; } elseif(strlen($content)&lt;50) {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result='&lt;h1&gt;'.$content.'&lt;/h1&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; } elseif(stripos($content,'__zhiwu55.com__')!==false) {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $firstPost=substr($content,0,strpos($content,'__zhiwu55.com__'));&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $comment=substr($content,strpos($content,'__zhiwu55.com__')+15);&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $comment=str_replace('__zhiwu55.cn__','&lt;/li&gt;&lt;li&gt;',$comment);&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result='&lt;hr&gt;&lt;h2&gt;下面是结果内容&lt;/h2&gt;&lt;hr&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;'.$firstPost.'&lt;br&gt;&lt;br&gt;&lt;strong&gt;评论如下:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;&lt;li&gt;'.$comment.'&lt;/li&gt;';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result='&lt;hr&gt;&lt;h2&gt;下面是结果内容&lt;/h2&gt;&lt;hr&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;'.$content;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; }<br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='search_keyword' &amp;&amp; !empty($_GET['keyword']))<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $tokenStr=file_get_contents('./appid.txt'); // 读取保存的appid和对应的密钥<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $tokenArr=explode('_ZW_',$tokenStr);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $appid=$tokenArr;&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $dataUrl=&quot;http://api.zhiwu55.net/v1/catch_data/search/?appid={$appid}&amp;keyword=&quot;.urlencode($_GET['keyword']);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data($dataUrl);<br /><li>}&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='hotnews')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/hotnews_json.html');<br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='top_news')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/updatenews_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='toutiao')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/toutiao.com_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='thepaper')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/thepaper.cn_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='sohu')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/sohu.com_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='sina')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/sina.com.cn_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='qq')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/qq.com_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='myzaker')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/myzaker.com_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='guokr')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/guokr.com_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='163')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/163.com_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='keyword01')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/E4BD93E882B2_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='keyword02')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/E8B4A2E7BB8F_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='keyword03')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/E6989FE5BAA7_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='keyword04')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/E59BBDE99985_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='keyword05')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/E5869BE4BA8B_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='keyword06')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/E5BDA9E7A5A8_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>if(!empty($_GET['ac']) &amp;&amp; $_GET['ac']=='keyword07')<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; $result=get_json_data('http://api.zhiwu55.net/v1/catch_data/batch_run/E7949FE6B4BB_json.html');&nbsp; &nbsp; &nbsp; &nbsp; <br /><li>}<br /><li>?&gt;<br /><li>&lt;!DOCTYPE html&gt;<br /><li>&lt;html&gt;<br /><li>&lt;head&gt;<br /><li>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;<br /><li>&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0,viewport-fit=cover&quot;&gt;<br /><li>&lt;/head&gt;<br /><li>&lt;body style=&quot;padding:16px;&quot;&gt;<br /><li>&lt;div style=&quot;margin-bottom:64px;line-height:32px;&quot;&gt;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=register&quot;&gt;【必须】注册appid&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=hotnews&quot;&gt;获取热搜榜单的内容&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=top_news&quot;&gt;获取最新内容&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=toutiao&quot;&gt;今日头条&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=thepaper&quot;&gt;澎拜新闻&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=sohu&quot;&gt;搜狐&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=sina&quot;&gt;新浪&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=qq&quot;&gt;腾讯网&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=myzaker&quot;&gt;ZAKER扎克&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=guokr&quot;&gt;果壳&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=163&quot;&gt;网易&lt;/a&gt;&lt;br&gt;&lt;br&gt;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=keyword01&quot;&gt;体育&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=keyword02&quot;&gt;财经&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=keyword03&quot;&gt;星座&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=keyword04&quot;&gt;国际&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=keyword05&quot;&gt;军事&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=keyword06&quot;&gt;彩票&lt;/a&gt;&nbsp; &nbsp; <br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;a href=&quot;./sdk_demo.php?ac=keyword07&quot;&gt;生活&lt;/a&gt;&lt;br&gt;&lt;br&gt;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;form action=&quot;./sdk_demo.php&quot; method=&quot;GET&quot;&gt;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;hidden&quot; name=&quot;ac&quot; value=&quot;search_keyword&quot;&gt;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 请输入简短精准关键词:<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;text&quot; name=&quot;keyword&quot; value=&quot;房地产&quot; style=&quot;padding:4px;height:30px;line-height:30px;width:300px;&quot;&gt;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;submit&quot; value=&quot;确定采集&quot; style=&quot;height:38px;&quot;&gt;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br /><li>&lt;/div&gt;<br /><li><br /><li>&lt;?php<br /><li>echo $result;<br /><li>/*********<br /><li><br /><li>接口所有的请求方式都是GET请求,即直接访问接口地址即可,简单、方便、快捷使用智伍云数据的API接口<br /><li><br /><li>注意事项:<br /><li><br /><li>1、请自行用接口,注册一个自己的appid和密钥,不要用公开泄露出去,因为同一个appid请求过于频繁,会禁止访问一段时间<br /><li><br /><li>2、所有的数据都有过期时间,获取到数据之后,请保存到自己的服务器,图片做好本地化存储<br /><li><br /><li>3、如果appid对应的密钥忘记了,或者密钥泄露出去,需要重置密钥,暂时只能联系智伍应用在线客服处理<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/register/<br /><li><br /><li>接口说明:注册一个访问智伍云数据的appid和密钥,获得拉取数据的权限,仅一个appid请求参数,其中appid为自定义32位的数字和字母的组合,注册成功之后,会返回32位的密钥,请把这个返回的密钥保存起来,为了安全10分钟过后,此接口不再显示注册appid的密钥<br /><li><br /><li>调用示例:http://api.zhiwu55.net/v1/catch_data/register/?appid=ZW3456789812X45678901234567890a1&nbsp;&nbsp;返回密钥:OuHZ552V20hi5ie3HCKTtyez3HR5ukhc&nbsp;&nbsp;再次提醒,请把返回的密钥保存起来,以备需要的时候使用。<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/search/<br /><li><br /><li>接口说明:根据特定的关键语,返回指定的内容,有二个参数,分别是appid和keyword,返回json数据格式,如果看上了近期的某一篇文章内容,可以直接把标题当作关键词来访问该接口<br /><li><br /><li>调用示例:http://api.zhiwu55.net/v1/catch_data/search/?appid=ZW3456789812X45678901234567890a1&amp;keyword=%E6%90%9E%E7%AC%91<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/content/<br /><li><br /><li>接口说明:这里一个最重要的接口,调用稍微麻烦一点,根据链接地址,拉取对应的数据和图片,需要用注册appid的32位密钥签名验证,一共有4个参数,分别如下<br /><li><br /><li>第1个参数:url,链接地址,请用接口返回的fromurl数值<br /><li>第2个参数:appid,即自己注册的appid<br /><li>第3个参数:t,当前的时间戳,请确保自己服务器的时间是中国的标准时间<br /><li>第4个参数:sign,根据参数计算出来的签名<br /><li><br /><li>下面是调用示例代码:<br /><li><br /><li>function get_sign($dataArr) //计算签名验证的函数<br /><li>{<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; if(!is_array($dataArr))<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 'no';<br /><li><br /><li>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br /><li><br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ksort($dataArr, SORT_STRING);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $string1 = '';<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach ($dataArr as $k =&gt; $v) {<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $v=urlencode($v);<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $string1 .= &quot;{$k}={$v}&amp;&quot;;<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return strtoupper(md5($string1));<br /><li>&nbsp; &nbsp; &nbsp; &nbsp; }<br /><li>}<br /><li>$mySignArr=array();<br /><li>$mySignArr['url']=urldecode($fromurl); //通过接口返回的fromurl链接地址<br /><li>$mySignArr['appid']='ZW3456789812X45678901234567890a1'; // 注册的appid<br /><li>$mySignArr['t']=time(); //当前时间戳<br /><li>$mySignArr['appsecret']='OuHZ552V20hi5ie3HCKTtyez3HR5ukhc'; // 密钥<br /><li>$mySignStr=get_sign($signArr); // 根据参数计算出来的签名<br /><li>$dataUrl=&quot;http://api.zhiwu55.net/v1/catch_data/content/?url={$fromurl}&amp;appid=ZW3456789812X45678901234567890a1&amp;t={$mySignArr['t']}&amp;sign={$mySignStr}&quot;;<br /><li>echo file_get_contents($dataUrl);<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/updatenews_json.html<br /><li><br /><li>接口说明:获取全网最新的内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/hotnews_json.html<br /><li><br /><li>接口说明:今日热搜榜单火爆全网的内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/toutiao.com_json.html<br /><li><br /><li>接口说明:今日头条最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/thepaper.cn_json.html<br /><li><br /><li>接口说明:澎拜新闻最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/sohu.com_json.html<br /><li><br /><li>接口说明:搜狐最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/sina.com.cn_json.html<br /><li><br /><li>接口说明:新浪最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/qq.com_json.html<br /><li><br /><li>接口说明:腾讯网最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/myzaker.com_json.html<br /><li><br /><li>接口说明:扎客新闻网最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/guokr.com_json.html<br /><li><br /><li>接口说明:果壳网最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>-----------------------------------------------------------------------------<br /><li><br /><li>接口地址:http://api.zhiwu55.net/v1/catch_data/batch_run/163.com_json.html<br /><li><br /><li>接口说明:网易最新内容,直接访问即可,返回json数据格式,隔一段时间自动更新内容<br /><li><br /><li>********/<br /><li>?&gt;<br /><li>&lt;/body&gt;<br /><li>&lt;/html&gt;</ol><br /><br />代码<em>, </em>自己的<em>, </em>复制<em>, </em>面的<em>, </em>存为

智伍应用 發表於 2022-8-25 14:58:48

下面的这二个插件,都是用上面的API接口二次开发的,大家可以参考看一下。<br /><br /><ignore_js_op><dl class="tattl"><dt></dt><dd><p class="attnm">【Discuz插件】众大云采集_v9.7.3.zip<p class="y">2022-8-25 14:58 上传</p><p>点击文件名下载附件</p></p><p>320.82 KB, 下载次数: 363</p><p></p><p class="xg2">众大云采集</p></dd></dl></ignore_js_op><ignore_js_op><dl class="tattl"><dt></dt><dd><p class="attnm">【Discuz插件】智伍云采集_zhiwu55_v2.0.2.zip<p class="y">2022-8-25 14:58 上传</p><p>点击文件名下载附件</p></p><p>105.58 KB, 下载次数: 333</p><p></p><p class="xg2">智伍云采集</p></dd></dl></ignore_js_op>
頁: [1]
查看完整版本: 【免费开源】利用云数据API接口,开发属于自己的采集器