Solved

auto login script (pref. PHP)

Posted on 2009-05-08
2
915 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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).

689 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