1.11M Members

Fetch the data from Other website

 
0
 

Thanks you all in advance.

I want to make a website showing the result of exams that are conducted in India. I want the user to enter his/her Roll Number in the form created at my website and as he/she press enter. His/her results should be displayed on the page.

I have a several websites as a demo. Those are using the same feature and displaying results.

http://www.examresults.net
http://www.indiaresults.com/

Hope I will get the results from the experts.

 
0
 

Does the website with the results provide an API?

 
0
 

I don't Think so... May be your answer is NO..

 
0
 

Contact those sites and ask them if it is ok to parse their results, if it is then just learn PHP and a post with Curl or other tools and then parse those data is nothing if you already know PHP….

 
-2
 

Its really coolto have websites like this...........

 
2
 

WARNING! It is not my intension to promote any unauthorized content parsing. By using the script I have provided below, you are responsible for any copyright violations and damages it may caused.

Knowledge is Power, but it can also destroy many things, if the probable consequencies are not evaluated, before hand.

Remote Server form structures
Let say, the remote site have a form structure like this

<form action="remoteProcess.php" method="post">
<input type="text" name="first_name">
<input type="text" name="last_name">
<input type="text" name="roll_number">
<input type="submit" name="submit" value="submit">
</form>

Assuming that the remoteProcess.php" will return "records not available" on all faults, and return something if roll_number is valid one.

On your Server

This simple cURL implementation can parse the remote response to your site.

## first you need to process your own form in your site.
if(isset($_POST['submit'])&&(!empty($_POST['fname'])) && (!empty($_POST['sname'])) && (!empty($_POST['roll_number']))){

## You must add more form filtering before sending it to the remote site.
## if all is well, prepare your data for remote trasmission using cURL

## define remote form processor script
$location = 'http://remoteSite.com/remoteProcessor.php';
## define your user agent
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $location );

$post_array = array(
    "first_name"=>preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['fname']),
    "last_name"=>preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['sname']),
    "roll_number" => $_POST['roll_number'],
    "submit" => "submit"
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 

## grab the response from the remote form processor
$response = curl_exec($ch);

## echo resonse or save as text or xml file. The choice are just too many to list. It is all up to you.
echo $response."<br/>";

## define what are you going to do if the remote processor sent out a fault response
if($response == "records not available"){

echo "roll_number is not valid";

## you can show your form here again default

}   


}

It is my assumption that the remote site will have at least a reliable response on fault, otherwise this script is not going to work. We can still make it work, but requires another tidious coding just to eliminate the bad and faulty result returned by the remote server.

Lastly, If the cURL approach did not help much.. You can parse their RSS feeds or XML file if it is allowed.

 
0
 

Thank you @Veedeo let me try this.

 
1
 

Hi,

Thanks for the kind message. Yes, try it. The above cURL script should be functional. I was using it for a long long time, including remote age verification, paypal authentication and some other things.

As an alternative, you can also do API ajax response if it is available from the remote site as what pritaeas suggested. If API or rss feeds is available, it should be the right choice than using cURL.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: