Dataoke.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. if ($t['kw']) {
  20. $q = [];
  21. if ($t['cid']) {
  22. $q['cid'] = $t['cid'];
  23. }
  24. if ($t['pid']) {
  25. $q['pid'] = $t['pid'];
  26. }
  27. if ($t['bids']) {
  28. $q['bids'] = $t['bids'];
  29. }
  30. //elseif ($t['cid']){
  31. // $new_url="/kw/" . $t['kw'] . ".html?cid=".$t['cid'];
  32. // } else{
  33. // $d=$t;
  34. // unset($d['kw']);
  35. // }
  36. if (count($q) > 0) {
  37. $s = "?" . http_build_query($q);
  38. } else {
  39. $s = "";
  40. }
  41. $new_url = "/kw/" . $t['kw'] . ".html" . $s;
  42. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  43. } else {
  44. if ($t['cid']) {
  45. $q = [];
  46. //http://www.taoqu88.com/tao.php?r=l&cid=4&s=t&u=1350274&original_id=8150
  47. if ($t['original_id']){
  48. $q['original_id'] = $t['original_id'];
  49. }
  50. if (count($q) > 0) {
  51. $s = "?" . http_build_query($q);
  52. } else {
  53. $s = "";
  54. }
  55. $new_url = "/category/" . $t['cid'] . ".html".$s;
  56. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  57. } else {
  58. if ($t['id']) {
  59. $new_url = "/product/" . $t['id'] . ".html";
  60. $content = str_replace('"' . $url . '"', '"' . $new_url . '"', $content);
  61. }
  62. }
  63. }
  64. ///index.php?r=index
  65. // if ($url=="/index.php?r=index"){
  66. // $content = str_replace($url, "/" , $content);
  67. // }
  68. }
  69. $content = str_replace('"/tao.php?r=p"', '"/pages/fengqiang.html"', $content);
  70. $content = str_replace('"/tao.php?r=nine"', '"/pages/nine.html"', $content);
  71. $content = str_replace('"/tao.php?r=ddq"', '"/pages/dongdong.html"', $content);
  72. $content = str_replace('"/tao.php?r=l"', '"/pages/haohuo.html"', $content);
  73. $content = str_replace('"/tao.php?r=index/index&u=1350274"', '"/"', $content);
  74. $content = str_replace('href="/tao.php?r=index/index"', 'href="/"', $content);
  75. $content = str_replace('https://cmsstatic.ffquan.cn//js/new_home.js', "/static/new_home.js", $content);
  76. // $content=str_replace('index.php', "tao.php", $content);
  77. return $content;
  78. }
  79. }