English 中文(简体)
• 如何把图像与php混为一谈
原标题:How to parse image feed with php

利用Wikipedia 预报系统链接,以了解某些世界知名特点/事件的主要形象。

例: (Stanislao Mattei)

This would show as following Wikipedia API Stanislao Mattei

Now my question I d like to parse the xml to get image url to be shown up

这里是愿意使用的单米代码,如果它正确使用ccKep。 ~

<?PHP
ini_set("user_agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");

$url = "http://en.wikipedia.org/w/api.php?action=query&list=allimages&aiprop=url&format=xml&ailimit=1&aifrom=Stanislao Mattei";

$xml = simplexml_load_file($url);

$extracts = $xml->xpath("/api/query/allimages");

var_dump($extracts);
?>

它应当作为阵列带来成果

如何从中获取所显示的形象的准确缩略语:

http://upload.wikimedia.org/wikipedia/en/a/a1/Stanislaus.jpg

将《刑法》纳入《刑法》

<img src="http://upload.wikimedia.org/wikipedia/en/a/a1/Stanislaus.jpg">

~ 感谢很多人

最佳回答

Did Youtries $xml->query->allimages->img->attributes()->url


你的法典将考虑这一点:

<?php
ini_set("user_agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");

$url = "http://en.wikipedia.org/w/api.php?action=query&list=allimages&aiprop=url&format=xml&ailimit=1&aifrom=Stanislao Mattei";

$xml = simplexml_load_file($url);

$url = $xml->query->allimages->img->attributes()->url;

echo "URL: ".$url . "<br/>";
echo  <img src=" .$url. "> ;

?>
问题回答

暂无回答




相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

Locating specific string and capturing data following it

I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...

热门标签