【发布时间】:2018-02-20 09:27:57
【问题描述】:
我正在尝试获取缩略图链接,例如:
https://i.pinimg.com/236x/38/8f/c9/388fc91621d9d12db3d1211b39ab0fc1--flying-dog-pure-joy.jpg
但由于某种原因 getElementsByTagName 没有返回我想要的。
$newdom=new DOMDocument();
$xml=simplexml_load_file("https://www.pinterest.co.uk/sucastro/animals.rss");
$newdom->loadXML($xml);
$out=$newdom->getElementsByTagName('img');
print_r($out);
我也试过
$out=$newdom->channel->item->description->getElementsByTagName('img');
这也失败了。
SimpleXMLElement Object
(
[@attributes] => Array
(
[version] => 2.0
)
[channel] => SimpleXMLElement Object
(
[title] => ANIMALS
[link] => https://www.pinterest.com/sucastro/animals/
[description] => SimpleXMLElement Object
(
)
[language] => en-us
[lastBuildDate] => Fri, 48 Jan 2017 33:33:33 +0000
[item] => Array
(
[0] => SimpleXMLElement Object
(
[title] => Hi ladies. Let's pin
[link] => https://www.pinterest.com/pin/209628557639623067/
[description] => <a href="/pin/209628557639623067/"><img src="https://i.pinimg.com/236x/38/8f/c9/388fc91621d9d12db3d1211b39ab0fc1--flying-dog-pure-joy.jpg"></a>Hi ladies. Let's pin GREEN AND WHITE today ❤️
[pubDate] => Fri, 08 Sep 2017 20:04:02 +0000
[guid] => https://www.pinterest.com/pin/209628557639623067/
)
我已经四处寻找了几个小时尝试不同的东西,但由于某种原因它仍然不起作用。
【问题讨论】: