add page class, and Page#links

master
Kanezoh 2021-08-19 08:44:05 +09:00
parent 6f8e9f743b
commit f0ac299bb3
2 changed files with 24 additions and 0 deletions

View File

@ -1,5 +1,6 @@
require "./file" require "./file"
require "./utils/element_matcher" require "./utils/element_matcher"
require "./page/link"
class MechanizeCr::Page < MechanizeCr::File class MechanizeCr::Page < MechanizeCr::File
include MechanzeCr::ElementMatcher include MechanzeCr::ElementMatcher
@ -33,6 +34,14 @@ class MechanizeCr::Page < MechanizeCr::File
end.to_a end.to_a
end end
def links
links = %w{a area}.map do |tag|
css(tag).map do |node|
PageContent::Link.new(node, @mech, self)
end
end.flatten
end
# generate form_with, forms_with methods # generate form_with, forms_with methods
# ex) form_with({:name => "login_form"}) # ex) form_with({:name => "login_form"})
# it detects form(s) which match conditions. # it detects form(s) which match conditions.

View File

@ -0,0 +1,15 @@
class MechanizeCr::PageContent::Link
property node : Lexbor::Node
property page : Page
property mech : Mechanize
def initialize(node, mech, page)
@node = node
@page = page
@mech = mech
# @attributes = node
# @href = node['href']
# @text = nil
# @uri = nil
end
end