| Events |
|
|
|
|
|
|
|
|
| Services |
|
|
|
|
| Interact |
|
|
| -
|
| -
|
|
|
|
|
| About Us |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: [vox-tech] PHP / CURL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] PHP / CURL
Hey it works... I can log into my password protected ebay.com and half.com account and grab any data I want :-) thanks a lot...
> php ebay.php > wget --load-cookies cookie.txt http://my.ebay.com/ws/eBayISAPI.dll?MyeBay
And this is the ebay.php code :
<?
$ebay_user_id = "yourid"; // ebay id
$ebay_user_password = "yourpassword"; // ebay password
$emailaddress = ""; //email address status about uploads will goto
$cookie_file_path = "cookie.txt"; // cookie file (dont bother changing)
// 1 - Get the Cookies required to login from the welcome login page
$LOGINURL = "http://signin.ebay.com/aw-cgi/eBayISAPI.dll?SignIn";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);
// 2 - Post Login Cookies and Login Information to Page http://signin.ebay.com/aw-cgi/eBayISAPI.dll
$LOGINURL = "http://signin.ebay.com/aw-cgi/eBayISAPI.dll";
$POSTFIELDS =
'MfcISAPICommand=SignInWelcome&siteid=0&co_partnerId=2&UsingSSL=0&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&userid='.
$ebay_user_id .'&pass='. $ebay_user_password;
$reffer = "http://signin.ebay.com/aw-cgi/eBayISAPI.dll?SignIn";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
?>
On 9/4/06, Dave Margolis <dave@silogram.net> wrote:
On Sep 4, 2006, at 6:48 PM, serendipitu serendipitu wrote:
> Thanks Dave... > > I have a RedHat Enterprise Linux 3 machine on which I installed: > curl 7.15.5 : with SSL > php 4.4.4 : with curl and command line interface
> > Unfortunately, the problem is a very basic one! I can't even read > a regular html webpage frpm an http server, let alone the https > stuff. For example: > > $LOGINURL = "
www.yahoo.com"; //or any other http webpage > $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) > Gecko/20030624 Netscape/7.1 (ax)"; > $ch = curl_init(); > curl_setopt($ch, CURLOPT_URL,$LOGINURL);
> curl_setopt($ch, CURLOPT_USERAGENT, $agent); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > $result = curl_exec ($ch); > curl_close ($ch); > print $result; > > I save the above lines in a
test.php file and then I type this on > linux command line: > > php -f test.php > or > > php test.php > > both just print the content of the .php file (the above lines!) > instead of the html webpage!!!!!! and I don't know what's wrong in
> here; that should be a small bug or a user mistake or something > like that.... > > Would you give me a sample php/curl code and the necessary steps > for running it on a linux command line? a simple one, something
> that does the same thing as "wget www.yahoo.com " for example. > > Thanks!
What you've got is perfect - except that every php script (web or CLI) needs to be wrapped in <? ... ?> tags.
So put <? at the beginning of your file and ?> at the end and you will be good to go. The script you have dumps the HTML content to standard output (you'd see a close approximation of the yahoo site if
you ran this in a web browsers). If you want this to behave exactly like wget, you'd have to add a few more lines (fopen(), fwrite ($result), fclose(), etc. to dump the contents to a file).
To get the data you really want, you'll probably have to study the
HTML a bit and come up with a regular expression to grab exactly what you want. Once you have that, you can do whatever you want - e-mail it to yourself, include the scraped data on another webpage, or whatever else you can come up with (send yourself a text message,
perhaps?).
Good luck, Dave
_______________________________________________ vox-tech mailing list vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech
|
|