Solved

auto login script (pref. PHP)

Posted on 2009-05-08
2
904 Views
Last Modified: 2012-05-06
I need to automate the collection of web data from a real estate site. I would much prefer that this be done in PHP as I can then easily write the data to my own database.

I need to login at (** login info removed **).

On the next page I need to select 'NV' from the drodown and 'clarke' as the county. I then need to input the start date as 05/13/2009 and end date as 05/20/2009 (clearly, all these would be variables which I can change myself).

The sales data should be displayed and I'm pretty sure I can extract this myself. (Bonus points if you have any quick suggestions on rapidly parsing the data).

I've tried using the cUrl libraries without success, but however you want to do it is fine (even suggest a third party provider who can *reliably* do this). The main thing is I need this *fast* (due to failure of third party provider)! As mentioned I would greatly prefer that this be done in PHP.

Many thanks, James.
0
Comment
Question by:smoothisland
2 Comments
 

Accepted Solution

by:
smoothisland earned 0 total points
ID: 24340760
Hi bolscott.

Luckily, in spite of the (non) help from the 'experts', I've managed to figure this out by myself.

The reference to .aspx was because asp servers and .aspx forms have a specific way and requirement of handling POST submissions. The solution is much different from what would have worked when posting to a PHP site.

I appreciate the concern re posting usernames and passwords on the site. There is nothing malicious that anyone could have done with this information and I felt it was necessary to show exactly what I needed to do.

I didn't want the app 'made'. I just needed specific advice re the points I made above. I am aware of terms of use. This app is for an individual client who just wants a mashup from two different sites for which he has paid a subscription.

For the record I am posting the solution. That way you and your "experts" can have a look at it and actually "help" someone who asks about this in the future.


<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://www.blahblah.com/login.aspx');

curl_setopt ($ch, CURLOPT_POST, 1);

curl_setopt ($ch, CURLOPT_POSTFIELDS, "__VIEWSTATE=%2FwEPDwULLTE0NDE2Njc1MzAP...blah blah blah"); 

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$store1 = curl_exec ($ch);
 

curl_setopt($ch, CURLOPT_URL, 'http://www.blahblah.com/ts.aspx');

curl_setopt ($ch, CURLOPT_POST, 1);

curl_setopt ($ch, CURLOPT_POSTFIELDS, "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTE0ODk5MjAw... blah blah blah");

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$store2 = curl_exec ($ch);
 

echo $store2;  // Do whatever you want...

curl_close ($ch);

?>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now