Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help! with getting form results (with cURL?)
Old 09-13-2005, 10:39 AM Help! with getting form results (with cURL?)
Novice Talker

Posts: 10
Trades: 0
I'm not very familiar with cURL, and not sure if it's the best way to do this, but I've been trying it based on what I've read.

Basically, there's a form on a government website that calculates your legislative district that I need to spoof. (perfectly legal, the organization i'm writing this for has permission). You can submit fields with a url, because it's a GET submission. (Something like http://www.governmentwebsite.com/rep...55&city=Austin), so it's easy to submit the form from my site.
But, when you use this URL then the site takes the form info into a CGI program, and somehow redirects you to a page where it spits out the results. The results page has the information I need to get both in the page content AND in the URL, so if I could scrape either info from the page I would have what I need. But how do I do this???

I've read everything I could find about screen scraping, but if I use cURL to scrape this:
http://www.governmentwebsite.com/rep...55&city=Austin
it only pulls information from the first page, before I'm redirected to the results page. How do I follow the form submission through a redirect and then pull information from the page I end up at?? Or even, based on the above URL, get the results page URL that I will end up at after getting redirected around?

I really appreciate any help anyone can give me!!! I've been pulling my hair out for days over this problem!!
bluepajamas is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-14-2005, 12:29 AM
Skilled Talker

Posts: 62
Trades: 0
Try instantiating cURL with the option to view the headers.

Find the redirect code within the headers (or, possibly, embedded in JavaScript on the page - but unlikely).

Follow the URL referenced in the redirect code you grabbed from the headers with another cURL request.

Scrape from the results page - may need to set a higher timeout to ensure the page will have time to be generated.
__________________

Please login or register to view this content. Registration is FREE
danlefree is offline
Reply With Quote
View Public Profile Visit danlefree's homepage!
 
Old 09-15-2005, 01:40 PM Solved
Novice Talker

Posts: 10
Trades: 0
Oh my god, thanks! I tried receiving headers before, but I must not have had the right combination of options set, and when I wrote the results to a database or file it would be blank. But your suggestion sent me looking in the right direction and I kept trying different things, and now it's working!!! Thanks for saving me a panic attack - I've got a deadline on Tuesday for the whole project!
bluepajamas is offline
Reply With Quote
View Public Profile
 
Old 09-21-2005, 11:18 PM
Skilled Talker

Posts: 62
Trades: 0
Glad to be of service - keep on codin'!
__________________

Please login or register to view this content. Registration is FREE
danlefree is offline
Reply With Quote
View Public Profile Visit danlefree's homepage!
 
Reply     « Reply to Help! with getting form results (with cURL?)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51163 seconds with 12 queries