?
Solved

auto login script (pref. PHP)

Posted on 2009-05-08
2
Medium Priority
?
929 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
1 Comment
 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

864 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