|
Posted by Johnny on 09/24/06 04:20
"richard" <don@john.son> wrote in message
news:ef40gn02qjn@news2.newsguy.com...
>
> "Johnny" <removethis.huuanito@hotmail.com> wrote in message
> news:GufRg.167$UJ2.61@fed1read07...
> >
> > "richard" <don@john.son> wrote in message
> > news:ef3taq02mp4@news2.newsguy.com...
> >> I am attempting to acquire certain information from a database.
> >> At this time they only have a simple search method.
> >> What I want to do is, at least eliminate the boring manual search
entries
> >> one at a time.
> >>
> >> Currently, I enter a number into the search box, press enter.
> >> I may go through dozens of numbers just to get one that has more
> >> information.
> >>
> >> So I was wondering if there was a way php could automate this process?
> >> Even if all it did was to tell me which numbers had more information.
> >> All those responding with the "no results found" page would be
> >> eliminated.
> >> I could then store the assigned numbers to an array and work from that.
> >>
> >> http://safer.fmcsa.dot.gov/CompanySnapshot.aspx
> >>
> >> Enter any number in the box. If no company is assigned that number, you
> > get
> >> the error page.
> >>
> >
> > hmmmm.... .apsx aren't you in the wrong group?
>
> Just covering all the bases.
>
well then, yes, there are ways that PHP can automate that process.
Here's kind of how I would approach it, off the top of my head:
Look at the source of the page and see the form that calls the
server with action "query.asp" and make a php page locally on your pc (that
has a web server running PHP, you got one o dem right?) that has all the
form vars and make it so you can set the
ones you want (get post or however).
Fer(sic) instance use curl
http://us3.php.net/manual/en/function.curl-setopt.php ) to do it like so:
<?php
for ($index=3; $index<10; ++$index) {
$sessions = curl_init();
curl_setopt($sessions,CURLOPT_URL,'http://safer.fmcsa.dot.gov/query.asp');
curl_setopt($sessions, CURLOPT_POST, 1);
$post_fields =
"searchtype=ANY&query_type=queryCarrierSnapshot&query_param=USDOT&query_stri
ng=";
$post_fields .= $index;
curl_setopt($sessions,CURLOPT_POSTFIELDS,$post_fields);
curl_setopt($sessions,CURLOPT_COOKIEJAR,'/home/usir/cookie.txt');
curl_setopt($sessions,CURLOPT_FOLLOWLOCATION,0);
curl_setopt($sessions, CURLOPT_HEADER , 1);
curl_setopt($sessions, CURLOPT_RETURNTRANSFER,1);
$my_load_page .= curl_exec($sessions);
}
echo $my_load_page;
?>
I'll leave you to figure out how to extract the data you need from what's
returned and how to make it do more than a few without choking, but you get
the gyst I'm sure.
PHP rules!
Navigation:
[Reply to this message]
|