如何从PHP或Jquery或两者中的URL获取图像? [英] How can I get image from url in PHP or Jquery or in both?

查看:90
本文介绍了如何从PHP或Jquery或两者中的URL获取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我,如何仅通过其网址获取特定网站的图片?就像在google搜索页面上所做的那样.我搜索过网络,但没有得到满意的答复.

Can anybody tell me, how can I get image for a particular site by its url only? As that is done on the google search page. I have searched web but I didn't get any satisfactory ans.

推荐答案

我不是体验开发人员,所以我只是尝试 该代码只能获取第一张图片

I'm Not Experience Developer so i just try This Code can fetch only first image

<?php
$url = 'http://stackoverflow.com/questions/7994340/how-can-i-get-image-from-url-in-php-or-jquery-or-in-both';
$data = file_get_contents($url);

if(strpos($data,"<img"))
{
    $imgpart1 = explode('<img src=',$data);
    $imgpart2 = explode('"',$imgpart1[1]);
    echo "<img src=".$imgpart2[1]." />";
}
?>

这篇关于如何从PHP或Jquery或两者中的URL获取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆