Developer Forum [ All Topics | New Topic ]

Thread: Trying to download prices with a linux script

I've tried several things to download to a linux server with HTTPS POST and I can't seem to get it to work, unfortunately I'm not as familiar with the POST DATA stuff. First I tried with the curl command: curl \ --cookie-jar /tmp/rapcookie \ --data "username=MYUSERNAME&password=MYPASSWORD" \ https://technet.rapaport.com/HTTP/Authenticate.aspx >/dev/null curl -L -o /tmp/rapdata --cookie /tmp/rapcookie https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx and all it passes to my file is a screen shot of the authentication screen. It was also tried with a perl script and that didn't work either: #!/usr/bin/perl use HTTP::Request::Common qw(POST); use LWP::UserAgent; $txtUser="MYUSERNAME"; $txtPassword="MYPASSWORDl"; $ua=LWP::UserAgent->new(); my $req= POST 'https://technet.rapaport.com/HTTP/Authenticate.aspx ', [txtUser=> $txtUser,txtPassword=>$txtPassword]; $content=$ua->request($req)->as_string; print $content Any ideas? HELP! Thank you.

>> add a comment
latyrrell
12/21/2009 11:53


3 Replies:

Hi, The curl looks like it is in the right direction. There is however no reason to deal with cookies. You just pass the parameters in POST DATA and the answer (if status code = 200) is the authentication ticket. Did you see the PHP code sample? it may help: http://technet.rapaport.com/Info/RapLink/SampleCode/PHP_Example.aspx So the second part, you should add this authentication ticket to the URL that you got back in the first response, so you should call: https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx?ticket=xxxxxxx You can also do this in one command, go to https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx and pass the username and password in post. You can send me screenshots, code samples I can use for our website to it@diamonds.net.

>> add a comment
Leo Muller
12/22/2009 1:02:00 AM
Regarding the PERL, again it would be great for me to get a sample code on our website. I don't know where you name the paramters that you send, but they must be called "username" and "password". So it may need to look like something like this (I don't know PERL): my $req= POST 'https://technet.rapaport.com/HTTP/Authenticate.aspx ', [username=> $txtUser,password=>$txtPassword]; Hope this helps, Regards, Leo

>> add a comment
Leo Muller
12/22/2009 1:06:00 AM
I just thought I'd post this since we have a resolution at last, that is simple and straight forward. Okay, here is the script that I am using to download the price files on my linux servers and it all seems to be working well. : # Wget must be version 1.10.2 or higher to support the "--post-data" command./ /LOGIN=myraplogin PASSWD=myrappasswd # Or ask if running the script manually and no login and password is provided [ "$LOGIN" -a "$PASSWD" ] || { echo -n " Enter Rapnet login: " read LOGIN echo -n "Enter Rapnet password: " read PASSWD } umask 000 error() { echo -e "\007$*" echo "Press Enter to continue" read scrap exit } wget --post-data="username=$LOGIN&password=$PASSWD" -O /tmp/round.csv "https://technet.rapaport.com/HTTP/Prices/CSV2_Round.aspx" wget --post-data="username=$LOGIN&password=$PASSWD" -O /tmp/pear.csv "https://technet.rapaport.com/HTTP/Prices/CSV2_Pear.aspx"

>> add a comment
latyrrell
1/7/2010 12:23:00 PM