Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6956329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:51:18+00:00 2026-05-27T14:51:18+00:00

I need a way to extract all form information on a webpage, via a

  • 0

I need a way to extract all form information on a webpage, via a PHP script.
so I have:

$url = “http://somewebpage.com/”;

the info I need is:
A list of all the forms on the webpage, and their options/atributes like:
A sample output would be as follows:

Form1: Form name: “login”, action: “login.php”, method: “GET”

  1. Input type: “text”, name: “usrname”
  2. Input type: “password”, name: “pass”

Form2: Form name: “login2”, action: “login2.php”, method: “POST”

  1. Input type: “text”, name: “usr”
  2. Input type: “password”, name: “pwd”

I use the following method to put the HTML contents of the webpage, into a variable:


// cURL
$browser_id = "some crazy browser";
$curl_handle = curl_init();
$options = array
(
CURLOPT_URL=>$url,
CURLOPT_HEADER=>true,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_FOLLOWLOCATION=>true,
CURLOPT_USERAGENT=>$browser_id
);
curl_setopt_array($curl_handle,$options);
$server_output = curl_exec($curl_handle);
curl_close($curl_handle);

Then I use this to remove the header info, and just keep the HTML stuff, cause otherwise DOM always gives me errors.

$server_output2 = substr($server_output, stripos($server_output, "<html"));

The for finding the forms, I use DOM

$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadHTML($server_output2);
$params = $dom->getElementsByTagName('form'); // Find Sections
$k=0;
foreach ($params as $param){
$forms[$k][0] = $params->item($k)->getAttribute('name');
$forms[$k][1] = $params->item($k)->getAttribute('action');
$forms[$k][2] = $params->item($k)->getAttribute('method');
$k++;
}

However my problem is, I often get errors from DOM, about unclosed tags, or other info. And I don’t want to get this info. How can I make it work?
Also my current code, only outputs the form info, not the inputs in a form, which I also want to know. How can I make this work? Thank you for your help.
You can view my project Remote Attack Vector (this is what I need it for) at http://sourceforge.net/projects/rav/files/
Or check out my website: http://tamasiweb.hu

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:51:19+00:00Added an answer on May 27, 2026 at 2:51 pm

    well, download this php lib

    http://sourceforge.net/projects/snoopy/

    class usage :

        $uri = "http://anysite.com/form";
    
        $snoopy = new Snoopy;
    
        if($snoopy->fetchform($uri)){
            $result = $snoopy->results;
        }
        echo $result; 
    

    hope that helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some kind xml content I need to extract the information and store
I have a bunch of javascript files I need to parse via PHP (I
I need a way to represent information about Weeks and Days as such: W1:
Trying to find an efficient way to extract all instances of items in an
What would be an optimal way, using Jsoup, to extract all HTML (either to
I have a bunch of strings I need to extract numbers from. They're in
I need to extract the src element from all image tags in an HTML
I have users sending emails with some text I need to extract. Each user's
Does anyone know of a way i can extract all jpg images from a
I'm seeking the fastest way to extract all tuple members from a list under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.