Dataoke.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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['kw']) {
  33. unset($q['kw']);
  34. if (count($q) > 0) {
  35. $s = "?" . http_build_query($q);
  36. } else {
  37. $s = "";
  38. }
  39. if ($t['page']) {
  40. $new_url = "/kw/" . $t['kw'] . "/page_" . $t['page'] . ".html" . $s;
  41. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  42. $url = htmlentities($url);
  43. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  44. } else {
  45. $new_url = "/kw/" . $t['kw'] . "/index.html" . $s;
  46. }
  47. // $new_url = "/kw/" . $t['kw'] . ".html" . $s;
  48. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  49. } else {
  50. if ($t['cid']) {
  51. unset($q['cid']);
  52. if (count($q) > 0) {
  53. $s = "?" . http_build_query($q);
  54. } else {
  55. $s = "";
  56. }
  57. if ($t['page']) {
  58. $new_url = "/category/" . $t['cid'] . "/page_" . $t['page'] . ".html" . $s;
  59. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  60. $url = htmlentities($url);
  61. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  62. } else {
  63. $new_url = "/category/" . $t['cid'] . "/index.html" . $s;
  64. }
  65. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  66. } else {
  67. if ($t['id']) {
  68. $new_url = "/product/" . $t['id'] . ".html";
  69. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  70. }
  71. if ($t['page'] && $t['r'] == 'l') {
  72. $new_url = "/page_" . $t['page'] . ".html";
  73. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  74. $url = htmlentities($url);
  75. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  76. }
  77. }
  78. }
  79. ///index.php?r=index
  80. // if ($url=="/index.php?r=index"){
  81. // $content = str_replace($url, "/" , $content);
  82. // }
  83. }
  84. $content = str_replace('"/tao.php?r=p"', '"/pages/fengqiang.html"', $content);
  85. $content = str_replace('"/tao.php?r=nine"', '"/pages/nine.html"', $content);
  86. $content = str_replace('"/tao.php?r=ddq"', '"/pages/dongdong.html"', $content);
  87. $content = str_replace('"/tao.php?r=l"', '"/pages/haohuo.html"', $content);
  88. $content = str_replace('"/tao.php?r=index/index&u=1350274"', '"/"', $content);
  89. $content = str_replace('href="/tao.php?r=index/index"', 'href="/"', $content);
  90. $content = str_replace('https://cmsstatic.ffquan.cn//js/new_home.js', "/static/new_home.js", $content);
  91. // $content=str_replace('index.php', "tao.php", $content);
  92. return $content;
  93. }
  94. }