| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?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);
- $rt = $ql->find("a")->attrs('href');
- $data = $rt->all();
- $data = array_unique($data);
- foreach ($data as $k => $url) {
- if (strstr($url, "tao.php") === false) {
- continue;
- }
- $query = parse_url($url);
- $t = parse_query($query['query']);
- $q = [];
- if ($t['cid']) {
- $q['cid'] = $t['cid'];
- }
- if ($t['pid']) {
- $q['pid'] = $t['pid'];
- }
- if ($t['bids']) {
- $q['bids'] = $t['bids'];
- }
- if ($t['original_id']) {
- $q['original_id'] = $t['original_id'];
- }
- if ($t['s']) {
- $q['s'] = $t['s'];
- }
- if ($t['kw']) {
- unset($q['kw']);
- if (count($q) > 0) {
- $s = "?" . http_build_query($q);
- } else {
- $s = "";
- }
- if ($t['page']) {
- $new_url = "/kw/" . $t['kw'] . "/page_" . $t['page'] . ".html" . $s;
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- $url = htmlentities($url);
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- } else {
- $new_url = "/kw/" . $t['kw'] . "/index.html" . $s;
- }
- // $new_url = "/kw/" . $t['kw'] . ".html" . $s;
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- } else {
- if ($t['cid']) {
- unset($q['cid']);
- if (count($q) > 0) {
- $s = "?" . http_build_query($q);
- } else {
- $s = "";
- }
- if ($t['page']) {
- $new_url = "/category/" . $t['cid'] . "/page_" . $t['page'] . ".html" . $s;
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- $url = htmlentities($url);
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- } else {
- $new_url = "/category/" . $t['cid'] . "/index.html" . $s;
- }
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- } else {
- if ($t['id']) {
- $new_url = "/product/" . $t['id'] . ".html";
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- }
- if ($t['page'] && $t['r'] == 'l') {
- $new_url = "/page_" . $t['page'] . ".html";
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
- $url = htmlentities($url);
- $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $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('href="/tao.php?r=index/index"', 'href="/"', $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;
- }
- }
|