module WWMD class Page #:section: Parsing convenience methods # methods that help parse and find information on a page including # access to forms etc. # grep for regexp and remove leading whitespace def grep(reg) self.body_data.grep(reg).map { |i| i.gsub(/^\s+/, "") } end # return this page's form (at index id) as a FormArray def get_form(id=nil) id = 0 if not id return nil if forms.empty? @forms[id].to_form_array end # return the complete url to the form action on this page def action(id=nil) id = 0 if not id act = self.forms[id].action return self.last_effective_url if (act.nil? || act.empty?) return @urlparse.parse(self.last_effective_url,act).to_s end # return an array of Element objects for an xpath search def search(xpath) self.scrape.hdoc.search(xpath) end # return an array of inner_html for each