带有查询参数的卷曲长URL
I am trying to curl a long URL like the following and save it into a file:
curl“ https:// Instagram.fwlg2-1.fna.fbcdn.net/v/t51.2885-15/2779019019_162489612877777777777777777777777777777777779859186579393913_N.N.JPGG? fna.fbcdn.net& _nc_cat = 102& _nc_ohc = gKuf2i9Vj5MAX-prxmR&edm=AABBvjUBAAAA&ccb=7-4&ig_cache_key=MjgxMDI0MDUzNDIyMTEzNzMyOQ%3D%3D.2-ccb7-4&oh=00_AT9BhJfQrBULLiNNXWfLQjhog3T8szmLRvMUEfWqE-cQIQ&oe=6266DFF7&_nc_sid=83d603"
doesnt save it to文件
I am trying to curl a long URL like the following and save it into a file:
where the filename should be only 277901819_162489612877754_7456098591865793913_n.jpg
curl "https://instagram.fwlg2-1.fna.fbcdn.net/v/t51.2885-15/277901819_162489612877754_7456098591865793913_n.jpg?stp=dst-jpg_e35&_nc_ht=instagram.fwlg2-1.fna.fbcdn.net&_nc_cat=102&_nc_ohc=gKuf2i9Vj5MAX-prxmR&edm=AABBvjUBAAAA&ccb=7-4&ig_cache_key=MjgxMDI0MDUzNDIyMTEzNzMyOQ%3D%3D.2-ccb7-4&oh=00_AT9BhJfQrBULLiNNXWfLQjhog3T8szmLRvMUEfWqE-cQIQ&oe=6266DFF7&_nc_sid=83d603"
doesnt save it to a file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,因此您尝试了
-O
和-O
选项,但它们似乎并没有做您想要的。这会失败,因为
-O
要求您自己指定文件名。使用-O
的正确方法是自己指定文件名:您并没有真正解释为什么这并不令人满意,因此我假设您是从用户输入或一个文件之类的东西。
这就是
-o
选项的目的。但这是另一个问题:取决于您的系统,也许是成功的,但是文件名不是您想要的。这试图在文件名中包含整个查询字符串。
这似乎是您可以用卷发所做的一切。您要么必须自己确定文件名(例如使用SED),并使用
-O
选项将其传递,要么需要使用除卷发以外的其他内容。我注意到 httpie 像您希望的那样处理此操作。也许您可以使用它而不是卷发?
Okay, so you have tried the
-o
and-O
options, but they don't seem to do what you want.This fails because
-o
requires you to specify the filename yourself. The correct way to use-o
is to specify the filename yourself:You haven't really explained why this isn't satisfactory, so I'll assume that you are getting the URL from user input or a file or something.
This is what the
-O
option is for. But it turns up another problem:Depending on your system, perhaps this succeeded, but the filename wasn't what you wanted. This is trying to include the entire query string in the filename.
This seems about all you can do with curl as it stands. You either have to determine the filename yourself (such as with sed) and pass it with the
-o
option, or you need to use something other than curl.I note that HTTPie handles this like you'd hope. Perhaps you could use it instead of curl?
You curl command is missing quote, it should be:
curl -o a.jpg 'https://instagram.fwlg2-1.fna.fbcdn.net/v/t51.2885-15/277901819_162489612877754_7456098591865793913_n.jpg?stp=dst- jpg_e35& _nc_ht = instagram.fwlg2-1.fn.fn.net.net& _nc_cat = 102&_nc_ohc = gkuf2i9vj5max-max-prxmr&amp& edmem = aabbvjub& amp; amp; cache& cache&cache&cache&cache&cache&cach&cache&cache∓ mp; c&c JGXMDI0MDUZNDIYMTEZNZMYOQ%3D%3D.2-CCB7-4& OH = 00_AT9BHJFQRBULLINNXWFLQJHOG3T8SZMLRRVMUEFWQE-CQIQ&amp& oe = 6266dff7& _nc_sid = 83d603'
You curl command is missing quote, it should be:
curl -o a.jpg 'https://instagram.fwlg2-1.fna.fbcdn.net/v/t51.2885-15/277901819_162489612877754_7456098591865793913_n.jpg?stp=dst-jpg_e35&_nc_ht=instagram.fwlg2-1.fna.fbcdn.net&_nc_cat=102&_nc_ohc=gKuf2i9Vj5MAX-prxmR&edm=AABBvjUBAAAA&ccb=7-4&ig_cache_key=MjgxMDI0MDUzNDIyMTEzNzMyOQ%3D%3D.2-ccb7-4&oh=00_AT9BhJfQrBULLiNNXWfLQjhog3T8szmLRvMUEfWqE-cQIQ&oe=6266DFF7&_nc_sid=83d603'