【问题标题】:Min width image scraper最小宽度图像刮刀
【发布时间】:2013-11-18 21:26:48
【问题描述】:

我正在使用此处开发的图像抓取功能:https://github.com/morshedalam/url-scraper-php

他们正在使用这个正则表达式来查找图像:

private $img_expression = '/<img[^>]+src=([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/';

这很好,但是,它会返回每一个图像(包括小图像)。很像 Pinterest、Facebook 等。我只对获取用作拇指的图像感兴趣,即宽度 > 200 像素。我意识到图像的尺寸可能没有在 html 源代码中定义。

你会怎么做?

干杯。

【问题讨论】:

    标签: php web-scraping


    【解决方案1】:

    您需要下载提取的图像,获取它们的大小并选择足够大的图像。

    有趣的是,对此有一个 SO 答案:php get all the images from url which width and height >=200 more quicker

    【讨论】:

      猜你喜欢
      • 2021-10-19
      • 2010-12-28
      • 2016-08-11
      • 2023-03-26
      • 1970-01-01
      • 2017-12-08
      • 2011-12-12
      • 2016-03-30
      • 2013-04-28
      相关资源
      最近更新 更多