phpphpquery

Automatically provide response to HTML form server-side using PHP


I am building an app that extracts data from a website and displays them in my app. I am using PHPQuery to extract data in my server-side code.

However, one page contains an .asp form with two dropdown menus. I need to select an option in both of them and then parse the resulting html. I need to do this server-side, so javascript doesn't seem to be the option.

How can I do so? Can it be done using PHPQuery or some other technology is required?

The page in question is: http://www.bput.ac.in/exam_schedule_ALL.asp


Solution

  • Since you're using PHP and phpQuery, I suggest you also try cURL.

    Explore what the form submits via JavaScript and replicate that via cURL. Do this to get the format of the posted (assumption) data, which you can then replicate in a cURL request to the same endpoints. JavaScript won't be necessary, and you can get the same results you need. In this case, you won't need the item mentioned next.

    Alternatively, if you have a browser, such as webkit, phantomJS, etc, you can write an automation script to run those steps and return the results, depending on exactly what you need returned. See more complete examples here: https://stackoverflow.com/a/17449757/573688 for how others suggest you do this. NOTE this is not usually necessary if you just need to emulate POST requests.

    This is a non-coded answer because it's not entirely clear what direction helps you the most.