add page title
parent
715fbfabb7
commit
52b77131dc
7
main.cr
7
main.cr
|
@ -4,6 +4,7 @@ agent = Mechanize.new
|
|||
agent.request_headers = HTTP::Headers{"Foo" => "Bar"}
|
||||
params = {"hoge" => "hoge"}
|
||||
page = agent.get("http://example.com/", params: params)
|
||||
puts page.code
|
||||
puts page.body
|
||||
puts page.css("h1").first.inner_text
|
||||
#puts page.code
|
||||
#puts page.body
|
||||
#puts page.css("h1").first.inner_text
|
||||
puts page.title
|
||||
|
|
|
@ -11,4 +11,8 @@ class MechanizeCr::Page < MechanizeCr::File
|
|||
def parser : Myhtml::Parser
|
||||
@parser ||= Myhtml::Parser.new(@body)
|
||||
end
|
||||
|
||||
def title
|
||||
title = parser.css("title").first.inner_text
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue