<?php
$post_fields = array(
'keyword1' => $_POST['keyword1'],
'Submit' => 'GO',
'binding' => null,
'landing_page' => 'content_list'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://contentproviderswebsite/searchpage.html'); // set the remote url
curl_setopt($ch, CURLOPT_POST, 1); // yes we are posting
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); // this is our POST data
curl_setopt($ch, CURLOPT_HEADER, 0); // no headers in output
curl_setopt($ch, CURLOPT_VERBOSE, 1); // verbose output, good for debugging
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// $ch will return the results of your POST when you execute
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); // the remote sites often check for a known user agent
$result = curl_exec ($ch);
curl_close($ch);
echo "<h1>Choose your cover</h1>";
$doc = new DOMDocument();
$doc->loadHTML($result);
$images = $doc->getElementsByTagName('img');
echo "images print statement";
print_r($images);
$pattern = '#<img src="(http://contentprovider.images.com[^"]+)[^>*]>#i';
$matches = array();
$num_matches = preg_match($pattern, $result, $matches[1]);
echo "matches print statement";
print_r($matches);
This is what I tried, and it hasn't generated images. I get
images print statementDOMNodeList Object ( ) matches print statementArray ( [1] => )
As you can see, I have assigned the "$images" variable to the $doc->getElements... statement.
My question is, in the $num_matches lines, should why do you use $result? Does $result now carry the info from $images and/or $doc variables?
$result stands in for "$subject" according to the PHP manual, and is the input string. But has the value of $result changed?
Thanks
spivey