ruby-readability icon indicating copy to clipboard operation
ruby-readability copied to clipboard

How to captured image when I used Readability::Document.new(source).content?

Open haluan opened this issue 9 years ago • 5 comments

haluan avatar Mar 22 '15 02:03 haluan

You can do .images instead of .content.

cantino avatar Mar 22 '15 17:03 cantino

If you mean you want the images to be embedded inside the content you can also try setting the option:

{
  tags: YOUR_TAGS + %w(img),
  remove_empty_nodes: false
}

You may need to add src to the list of attributes as well.

plcstevens avatar May 20 '15 11:05 plcstevens

When importing content from medium.com you need to add "figure" to allowed tags

polakowski avatar Jan 07 '16 12:01 polakowski

@haluan, is it solved for you?

matheussilvasantos avatar Sep 12 '19 10:09 matheussilvasantos

I have the same problem. Adde img and remove_empty_nodes: false are doing nothing and still the images are still being removed from content.

url = "https://medium.com/better-advice/20-things-most-people-learn-too-late-in-life-23674cdbd75c"
body = open(url).read
rbody = Readability::Document.new(body, :tags => %w[div p img a figure], :attributes => %w[src href figure], :remove_empty_nodes => false).content
rbody.content

ryzalyusoff avatar Nov 04 '20 14:11 ryzalyusoff