Posted by mouseit101 on 09/08/06 01:51
Hi, I'm writing a script that would (hopefully) search google images
for whatever, and then return a list of URLs for the image. Right now I
have:
$dom = new DomDocument();
$url = "http://images.google.com/images?q=hello";
$dom->loadHTMLFile($url);
$sxe = simplexml_import_dom($dom);
foreach($sxe->xpath('//img') as $node)
{
echo $node->src;
}
What this is supposed to do (line by line):
Make a new DomDocument
Define $url
load the HTML file from $url
make a simpleXML object from the loaded DOM
go through all the image tags (using a DomNodeList w/ xpath) and print
out the src attribute of the node.
What it does:
Prints nothing.
Just wondering if anyone knew what ws goin on.
Thanks.
Navigation:
[Reply to this message]
|