duanbaque4230 2010-07-26 13:58
浏览 39
已采纳

刮取网站URL以获取图像的路径

I'm hacking together a simple php script that will build a list of photo albums I have on my Facebook fan page.

Facebook kindly offer the Graph API which gives me back a nice list of Albums, however they no longer provide the path of the default album image.

I want to write a PHP script that loads an album url via curl and somehow grab the path of the first image in the table that contains the thumbnails. This would be the "src" value of the first img tag that has a class of "UIPhotoGrid_Image".

The block of layout code that contains the good stuff looks like this:

<div id="album_container">
    <div class="UIPhotoGrid_Container UIPhotoGrid_DefaultPadding">
        <table class="UIPhotoGrid_Table" cellpadding="0" cellspacing="0">
            <tr>
                <td class="UIPhotoGrid_TableCell">
                    <a class="UIPhotoGrid_PhotoLink clearfix" href="http://www.facebook.com/photo.php?pid=5004658&amp;id=20785087272"><img class="UIPhotoGrid_Image img" src="http://photos-e.ak.fbcdn.net/hphotos-ak-snc4/hs080.snc4/35354_422883027272_20785087272_5004658_704231_s.jpg" onload="this.fb_loaded = true;" /></a>
                </td>
                <td class="UIPhotoGrid_TableCell">
                    <a class="UIPhotoGrid_PhotoLink clearfix" href="http://www.facebook.com/photo.php?pid=5004659&amp;id=20785087272"><img class="UIPhotoGrid_Image img" src="http://photos-c.ak.fbcdn.net/hphotos-ak-snc4/hs080.snc4/35354_422883032272_20785087272_5004659_6158094_s.jpg" onload="this.fb_loaded = true;" /></a>
                </td>
                <td class="UIPhotoGrid_TableCell">
                    <a class="UIPhotoGrid_PhotoLink clearfix" href="http://www.facebook.com/photo.php?pid=5004660&amp;id=20785087272"><img class="UIPhotoGrid_Image img" src="http://photos-f.ak.fbcdn.net/hphotos-ak-snc4/hs080.snc4/35354_422883037272_20785087272_5004660_1787119_s.jpg" onload="this.fb_loaded = true;" /></a>
                </td>
            </tr>
        </table>
    </div>
</div>

This sadly, is beyond my current coding capabilities... Any ideas?

  • 写回答

3条回答 默认 最新

  • dongmei8071 2010-07-26 14:06
    关注

    You could use phpsimpledom to grab the path using a jQuery style syntax.

    Note: Facebook probably have several image clusters, so the URL to the photo may change over time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大