【问题标题】:How to crawl this type of urls如何抓取此类网址
【发布时间】:2012-11-10 17:43:09
【问题描述】:

我正在使用 PHP Simple HTML DOM Parser。 我怎样才能让它通过这样的 URL 进行爬网。 http://www.example.com/categories/index.php?id=number from 1-1000&文章

通过 URL 爬行应该是这样的:

http://www.example.com/categories/index.php?id=1&article First URL
http://www.example.com/categories/index.php?id=2&article Second URL
http://www.example.com/categories/index.php?id=3&article Third URL
etc..

【问题讨论】:

    标签: php web-crawler


    【解决方案1】:

    使用for 语句?

    制作一个id=$id爬取的页面,查询字符串中带有$id,下载后自动重新加载页面,每次递增$id直到1000?

    【讨论】:

      【解决方案2】:

      您可以导出 post 方法。如果您不使用 1-500 之间的所有数字,则必须使用爆炸和列表导出它

      <?php
      list($a,$b,$c)=explode(' ','number from 1-5');
      list($start,$end)=explode('-',$c);
      for( $i=$start ; $i<=$end; $i++)
          echo "http://www.example.com/categories/index.php?id={$i}&article".'<br/>';
      ?>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-04-22
        • 1970-01-01
        • 1970-01-01
        • 2015-05-25
        • 1970-01-01
        • 2021-07-06
        • 2020-09-03
        相关资源
        最近更新 更多