Blogger Information
Blog 55
fans 0
comment 0
visits 59433
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php爬图片
南鸢离梦的博客
Original
1045 people have browsed it

composer 安装 QueryList

composer require jaeger/querylist

  1. <?php
  2. namespace app\index\controller;
  3. use QL\QueryList;
  4. use think\facade\View;
  5. class Index
  6. {
  7. public function index()
  8. {
  9. for ($i=2;$i<5;$i++){
  10. $ql = QueryList::get("https://mm.enterdesk.com/$i.html");
  11. $images[] = $ql->find('.egeli_pic_dl>dd>a>img')->attrs('src')->toArray();
  12. }
  13. foreach ($images as $k => $v){
  14. foreach ($v as $j => $l){
  15. $newImg[] = $l;
  16. }
  17. }
  18. dump($newImg);
  19. View::assign('num',sizeof($newImg));
  20. View::assign('images',$newImg);
  21. return View::fetch('index');
  22. }
  23. }
  24. <!DOCTYPE html>
  25. <html lang="en">
  26. <head>
  27. <meta charset="UTF-8">
  28. <title>Title</title>
  29. <style>
  30. body{
  31. margin: 0;
  32. padding: 0;
  33. }
  34. ul{
  35. padding: 0;
  36. }
  37. li{
  38. display: inline-block;
  39. width: 23.5%;
  40. margin: 0 auto;
  41. padding: 10px;
  42. }
  43. img{
  44. margin: 0;
  45. width: 100%;
  46. }
  47. </style>
  48. </head>
  49. <body>
  50. <ul>
  51. <input type="hidden" id="num" value="{$num}">
  52. {volist name="images" id="v"}
  53. <li><img src="{$v}" alt=""></li>
  54. {/volist}
  55. </ul>
  56. <script>
  57. window.onload=function()
  58. {
  59. var num = document.getElementById("num").value;
  60. alert('本次爬虫爬到了'+num+'张图片')
  61. }
  62. </script>
  63. </body>
  64. </html>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post