-- Steve Rayner <[email protected]> wrote
(on Monday, 28 March 2011, 03:18 PM +0100):
> I am trying to get the value of the 's' parameter in this http responce;
>
> <HTML>
> <HEAD>
> <link rel="stylesheet" type="text/css" href="/server/server.css">
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
> <META HTTP-EQUIV="Content-Language" CONTENT="en-GB">
> <TITLE>Site Title - System Administrator logged on at 14:46:16</TITLE>
> </HEAD>
> <FRAMESET COLS="31%,69%" FRAMEBORDER=1>
> <FRAME SRC="/site/temp/09c0b4d909128c1534_1301319992_c.html.windows-1252">
> <FRAME
> SRC="/cgi-bin/site/menu.pl?s=09c0b4d909128c1534&lang=0&product=abc&choice=sav;topic=ddd"
> name="body">
> </FRAMESET>
> </HTML>
>
> Is there any way to use Zend_Http_Response to get access to the
> <FRAME> html elements, so that i can extract the value after the s= ?
Use Zend_Dom_Query, a smattering of DOM, and some PHP built-ins:
$s = false;
$dom = new Zend_Dom_Query($html);
foreach ($dom->query('frameset frame') as $node) {
$src = $node->attributes->getNamedItem('src')->nodeValue;
$qs = parse_url($src, PHP_URL_QUERY);
parse_str($qs, $params);
if (isset($params['s'])) {
$s = $params['s'];
break;
}
}
if (!$s) {
throw Exception('Not found!');
}
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]