I have this setup in which my script tries to access any webpage and gets the source.

what i need is the values of forms and its respective input text variables should be moved to an array (respectively) as shown below

form1
var1a
var1b
form2
var2b
form3
var3a
var3b
var3c

Each variables should converge under their parent form.
I have coded this in DOM , actually i am nearing to the conclusion but i need help.

Here is the code..

Code:

<?php

$target_url = "www.dnschart.com";

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$html= curl_exec($ch);

$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);

$hrefs1=$dom->getElementsByTagName("form");


for ($i = 0; $i < $hrefs1->length; $i++)
{
    $href = $hrefs1->item($i);
    $url = $href->getAttribute('action');
    echo $url;
    echo "<br>";
    flush();
    $hrefs2=$dom->getElementsByTagName("input");
    for ($j = 0;$j < $hrefs2->length; $j++)
    {
    $hrefx = $hrefs2->item($j);
    $urlx = $hrefx->getAttribute('text');
        if(strtolower($urlx)=='text')
        {
        $urlx = $hrefx->getAttribute('name');
        echo $urlx;
        flush();
        }
    }    

}

?>

I am getting only the form attributes but not its child attributes.😕

Hope you could help !

    Write a Reply...