Solved

auto login script (pref. PHP)

Posted on 2009-05-08
2
903 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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encode a password 2 36
How to remove decimals from calculation amount 8 22
session dropped in IE 10 18
Do we need servers??? 5 109
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…

763 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