Dataoke.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace Heanup\App\Api\Model;
  3. use QL\QueryList;
  4. use function GuzzleHttp\Psr7\parse_query;
  5. class Dataoke
  6. {
  7. public static function parse($content)
  8. {
  9. $ql = QueryList::html($content);
  10. $rt = $ql->find("a")->attrs('href');
  11. $data = $rt->all();
  12. $data = array_unique($data);
  13. foreach ($data as $k => $url) {
  14. if (strstr($url, "tao.php") === false) {
  15. continue;
  16. }
  17. $query = parse_url($url);
  18. $t = parse_query($query['query']);
  19. $q = [];
  20. if ($t['cid']) {
  21. $q['cid'] = $t['cid'];
  22. }
  23. if ($t['pid']) {
  24. $q['pid'] = $t['pid'];
  25. }
  26. if ($t['bids']) {
  27. $q['bids'] = $t['bids'];
  28. }
  29. if ($t['original_id']) {
  30. $q['original_id'] = $t['original_id'];
  31. }
  32. if ($t['s']) {
  33. $q['s'] = $t['s'];
  34. }
  35. if ($t['kw']) {
  36. unset($q['kw']);
  37. if (count($q) > 0) {
  38. $s = "?" . http_build_query($q);
  39. } else {
  40. $s = "";
  41. }
  42. if ($t['page']) {
  43. $new_url = "/kw/" . $t['kw'] . "/page_" . $t['page'] . ".html" . $s;
  44. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  45. $url = htmlentities($url);
  46. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  47. } else {
  48. $new_url = "/kw/" . $t['kw'] . "/index.html" . $s;
  49. }
  50. // $new_url = "/kw/" . $t['kw'] . ".html" . $s;
  51. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  52. } else {
  53. if ($t['cid']) {
  54. unset($q['cid']);
  55. if (count($q) > 0) {
  56. $s = "?" . http_build_query($q);
  57. } else {
  58. $s = "";
  59. }
  60. if ($t['page']) {
  61. $new_url = "/category/" . $t['cid'] . "/page_" . $t['page'] . ".html" . $s;
  62. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  63. $url = htmlentities($url);
  64. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  65. } else {
  66. $new_url = "/category/" . $t['cid'] . "/index.html" . $s;
  67. }
  68. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  69. } else {
  70. if ($t['id']) {
  71. $new_url = "/product/" . $t['id'] . ".html";
  72. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  73. }
  74. if ($t['page'] && $t['r'] == 'l') {
  75. $new_url = "/page_" . $t['page'] . ".html";
  76. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  77. $url = htmlentities($url);
  78. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  79. }
  80. }
  81. }
  82. ///index.php?r=index
  83. // if ($url=="/index.php?r=index"){
  84. // $content = str_replace($url, "/" , $content);
  85. // }
  86. }
  87. $content = str_replace('"/tao.php?r=p"', '"/pages/fengqiang.html"', $content);
  88. $content = str_replace('"/tao.php?r=nine"', '"/pages/nine.html"', $content);
  89. $content = str_replace('"/tao.php?r=ddq"', '"/pages/dongdong.html"', $content);
  90. $content = str_replace('"/tao.php?r=l"', '"/pages/haohuo.html"', $content);
  91. $content = str_replace('"/tao.php?r=index/index&u=1350274"', '"/"', $content);
  92. $content = str_replace('href="/tao.php?r=index/index"', 'href="/"', $content);
  93. $content = str_replace('https://cmsstatic.ffquan.cn//js/new_home.js', "/static/new_home.js", $content);
  94. // $content=str_replace('index.php', "tao.php", $content);
  95. return $content;
  96. }
  97. }