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