提取的url不显示图像 [英] extracted url does not shows the images
本文介绍了提取的url不显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我是php的新手,需要一些帮助。
我想做的是提取网址如下:
http://www.weatherzone.co.nz/north-island/wellington
但我是没有获得图片标签。
i已完成以下操作。
Hi there,
I am rookie in php and need some help.
what i am trying to do is to extract the url which is as follows:
http://www.weatherzone.co.nz/north-island/wellington
However i am not getting the image tags.
i have done the following.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.weatherzone.co.nz/north-island/wellington');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
echo $output;
$url="http://www.weatherzone.co.nz/north-island/wellington";
$html = file_get_contents($url);
$doc = new DOMDocument();
@$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('img');
foreach ($tags as $tag) {
echo $tag->getAttribute('src');
}
此代码仅获取网站内容,但不显示来自外部网址的图片。
任何帮助都将是赞赏!!!
提前致谢。
This code only gets me the website content but doesnt shows the images from the external url.
Any help would be appreciated!!!
Thanks in advance.
推荐答案
ch = curl_init();
curl_setopt(
ch = curl_init(); curl_setopt(
ch,CURLOPT_URL,' http:// www.weatherzone.co.nz/north-island/wellington'跨度>);
curl_setopt(
ch, CURLOPT_URL, 'http://www.weatherzone.co.nz/north-island/wellington'); curl_setopt(
ch,CURLOPT_RETURNTRANSFER,1);
ch, CURLOPT_RETURNTRANSFER, 1);
这篇关于提取的url不显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文