开发者

Ruby Mechanize retrieve headers

开发者 https://www.devze.com 2023-03-05 07:09 出处:网络
I\'m using mechanize for web inspection, when I get a URL I get a refresh URL in the headers: meta http-equiv=\"refresh\" content=\"2;url=/html/Splash.action?splash=\"

I'm using mechanize for web inspection, when I get a URL I get a refresh URL in the headers:

meta http-equiv="refresh" content="2;url=/html/Splash.action?splash="
开发者_如何学Python

When I ask to mechanize to list the metadata I do this:

pp $page.meta

I get:

Mechanize::Page::Meta
  ""
  "http://localhost/html/Splash.action?splash="

How can I cleanly retrieve the refresh URL?

Thanks


This works:

$page.meta.first.href


Either it's a bug in mechanize, or there's something wrong with the html, as it should have this is meta. BTW, Mechanize also has #follow_meta_refresh attribute, which is false by default.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号