wombat icon indicating copy to clipboard operation
wombat copied to clipboard

How do I remove a node?

Open ZephiroRB opened this issue 6 years ago • 0 comments

Thanks for the work you do with this gem

Hello, I am need remove multiples nodes with class css

.media
.ads
.cite-content

How do I remove a nodes css?:

class ListCrawler
      include Wombat::Crawler

      base_url "https://rpp.pe"
      path "/politica/actualidad/ministerio-publico-las-discrepancias-entre-pablo-sanchez-y-pedro-chavarry-noticia-1142342"

      explore css: '#article-body' do |e|
        e remove: '.media'
        e remove: '.ads'
        e remove: '.cite-content'
      end
end
pp ListCrawler.new.crawl

#ERRORR!!

With standalone gem Mechanize works

 mechanize = Mechanize.new { |agent|
  agent.user_agent_alias = 'Mac Safari'
}

page = mechanize.get('https://rpp.pe/politica/actualidad/ministerio-publico-las-discrepancias-entre-pablo-sanchez-y-pedro-chavarry-noticia-1142342')

text = page.at('#article-body')

text.at_css(".media").remove
text.at_css(".ads").remove
text.at_css(".cite-content").remove

puts text

Someone who is an expert can help me?

Thanks!

ZephiroRB avatar Aug 13 '18 18:08 ZephiroRB