我在curl/bash 中缺少什么?

发布于 2025-01-10 22:19:51 字数 1448 浏览 0 评论 0原文

哟,我正在尝试使用curl 将文件下载/上传到rapidgator.net。 但下载是最重要的任务;过去我很容易做到这一点,但是 现在它只下载首页。

这个想法是加载一个包含所需url的文件,然后将其作为参数传递给curl,首先我

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

通过api制作一个cookie文件,这应该是正确的,但它只生成一个有效的cookie,并且

https://rapidgator.net/api/v2/user/[email protected]&password=thepassword
 > /dev/null

回复符合预期的方式(如此处所述),但它没有保存到指定的cookie文件。

一旦生成了 cookie,就会创建文件列表并以下一种方式进行下载

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

,但它只下载常规的首页,所以看起来 cookie 不起作用。 由于清单很长,因此一项一项地进行是不可行的。

那么如何用curl生成cookie并下载呢?

提前致谢。

更新
感谢您的支持。 详细信息是 api 本身,因为

username

一旦更新

login

以生成 cookie,curl 下载就仅调整为

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

感谢支持!

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":"[email protected]","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/[email protected]&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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文