0

Yo there, I'm trying to use curl to download/upload files to rapidgator.net. But download is the most important task; in the past I've done this easily, but now it is downloading only the front page.

The idea is to load a file with the urls required and then pass it to curl as argument, first I make a cookie file

curl -X POST \
--cookie-jar cookie\
-H "Content-type: application/json" \
-d '{"username":"somebox@somegmail.com","password":"thepassword"}' \
https://rapidgator.net/api/v2/user/login? > /dev/null

By the api, this should have been right, but it only generates a valid cookie with

https://rapidgator.net/api/v2/user/?login=somemail@someplace.com&password=thepassword
 > /dev/null

The reply is conform in the expected way (as documented here ), but it isn't saving to the stated cookie file.

And once the cookie is generated, the filelist is created and the download is made in the next way

for i in $(cat filelist) \ 
      do 
          curl -x -L -O -C - --cookie cookie_file -s "$url/$i" \
done

But it only download the regular front page, so it seems the cookie isn't working. And since there are long lists, doing one by one isn't viable.

So how can generate the cookie and download with curl?

Thanks in advance.

UPDATE
Thanks for the support. The detail is the api itself, since

username

is implemented as

login

once this is updated to generate the cookie the curl download is only adjusted to

  curl -L -O -C - --cookie cookie_file $i \  

Thanks for the support!

avelardo
  • 175
  • 1
  • 10
  • 1
    How do you create `filelist`? – Barmar Mar 01 '22 at 21:07
  • 1
    APIs don't usually use cookies. The Login API returns an access token that you're supposed to use in future requests. Cookies are normally only used by web pages. – Barmar Mar 01 '22 at 21:09
  • 1
    Is that another copying error? You have a different filename in `--cookie-jar` than `--cookie`. – Barmar Mar 01 '22 at 21:10
  • I dump it from the clipboard one line at the time, and make the for loop to avoid the format limitations of -K argument, the token is saved in the cookie, but I don't know how to pass it alone to curl. – avelardo Mar 01 '22 at 21:12
  • 1
    You can pass it as a URL parameter, e.g.: `/api/v2/user/info?token=arsd4h37ecfkdqd16uolf5nai1` – Barmar Mar 01 '22 at 21:14
  • 1
    Or `/api/v2/file/download?file_id=n6eg62ga6hr5r6hjpepfh7asf2&token=n6eg62ga6hr5r6hjpepfh7asf2` to download a file. – Barmar Mar 01 '22 at 21:15
  • This question is very close to the this question: https://stackoverflow.com/questions/30760213/save-cookies-between-two-curl-requests Not a duplicate but close relative. The answers might provide a solution direction. – Dudi Boy Mar 01 '22 at 21:34

0 Answers0