| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace Heanup\App\Api\Model;
- use QL\QueryList;
- use function GuzzleHttp\Psr7\parse_query;
- class Dataoke
- {
- public static function parse($content)
- {
- $ql = QueryList::html($content);
- // 元数据采集规则
- $rules = [
- 'link' => ["a", "href"]
- ];
- // 切片选择器
- $rt = $ql->find("a")->attrs('href');
- $data = $rt->all();
- $data = array_unique($data);
- foreach ($data as $url) {
- // if (strstr($url, "tao.php") === false) {
- // continue;
- // }
- $_url=str_replace("/tao.php?", "", $url);
- $_url=str_replace("/index.php?", "", $_url);
- $t = parse_query($_url);
- if ($t['kw']) {
- // if ($t['bids']){
- // $new_url="/kw/" . $t['kw'] . ".html?bids=".$t['bids'];
- // }elseif ($t['cid']){
- // $new_url="/kw/" . $t['kw'] . ".html?cid=".$t['cid'];
- // } else{
- // $d=$t;
- // unset($d['kw']);
- // }
- $new_url="/kw/" . $t['kw'] . ".html?".http_build_query($t);
- $content = str_replace($url, $new_url, $content);
- }else{
- if ($t['cid']) {
- $content = str_replace($url, "/category/" . $t['cid'] . ".html", $content);
- }else{
- if ($t['id']) {
- $content = str_replace($url, "/product/" . $t['id'] . ".html", $content);
- }
- }
- }
- ///index.php?r=index
- // if ($url=="/index.php?r=index"){
- // $content = str_replace($url, "/" , $content);
- // }
- }
- $content=str_replace('"/tao.php?r=p"', '"/pages/fengqiang.html"', $content);
- $content=str_replace('"/tao.php?r=nine"', '"/pages/nine.html"', $content);
- $content=str_replace('"/tao.php?r=ddq"', '"/pages/dongdong.html"', $content);
- $content=str_replace('"/tao.php?r=l"', '"/pages/haohuo.html"', $content);
- $content=str_replace('"/tao.php?r=index/index&u=1350274"', '"/"', $content);
- $content=str_replace('https://cmsstatic.ffquan.cn//js/new_home.js', "/static/new_home.js", $content);
- // $content=str_replace('index.php', "tao.php", $content);
- return $content;
- }
- }
|