gpt4 book ai didi

ruby - 如何在 Ruby 中使用 mechanize 执行 Head 请求

转载 作者:数据小太阳 更新时间:2023-10-29 07:29:01 24 4
gpt4 key购买 nike

我可以使用 Faraday (Faraday.head url) 执行 HEAD 请求,但我在当前项目中使用 Mechanize。

我想在不下载文件的情况下从标题(文件名)中获取一个值。 Mechanize gem 是否提供这样的选项?我正在使用 v2.0。

最佳答案

就像get 但它是head:

page = agent.head 'http://www.google.com/'
page.body.length
#=> 0
page.header.keys
#=> ["date", "expires", "cache-control", "content-type", "set-cookie", "p3p", "server", "x-xss-protection", "x-frame-options", "transfer-encoding"]

关于ruby - 如何在 Ruby 中使用 mechanize 执行 Head 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13872530/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com