vitalie / webshot Goto Github PK
View Code? Open in Web Editor NEWCaptures a web page as a screenshot.
License: MIT License
Captures a web page as a screenshot.
License: MIT License
Hi,
I have one site related to articles, So In that, We have added one feature for take screenshots from where our articles are and store it in our site. For take this screenshots job, we have used sidekiq.
So issue is that, Somehow duplicate screenshots are display, I have tried my best to achieve this issue with many possible solutions but unable to solve this issue with any of that possible solutions.
Please help us for this issue.
Thanks in advance,
Hi
I have been trying to use webshot in a multi threaded / concurrent environment but phantomjs is producing unexpected results. Sometimes it works but on occassions if multiple background jobs are using webshot to grab the url screenshots, it crashes phantomjs with a fatal error
Is phantomjs not meant to be run in a multi threaded environment or if so can you please provide some form of setup instructions?
thanks
Hey so nice gem. Issue I am having is rendering screenshots of some sites. Example github.com.
ws.capture 'http://github.com', 'github.png'
Webshot::WebshotError: Could not fetch page: "http://github.com", error code:
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/webshot-0.0.7/lib/webshot/screenshot.rb:77:in `capture'
from (irb):5
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0.beta2/lib/rails/commands/console.rb:110:in `start'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0.beta2/lib/rails/commands/console.rb:9:in `start'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/railties-4.2.0.beta2/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
from /Users/fabio/Sites/sevenzio/bin/rails:8:in `<top (required)>'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:242:in `load'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:242:in `block in load'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
from /Users/fabio/.rvm/gems/ruby-2.1.3/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:242:in `load'
from /Users/fabio/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/fabio/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from ws.capture 'http://google.com', 'google.png'
I ran into this issue before and the culprit was SSL certs with phantomjs. What you need to do is pass in the following options to phantomjs:
phantomjs --ignore-ssl-errors=true --ssl-protocol=any YOURSCRIPT
Since Capybara is controlling the phantomjs instance - I'm not sure how you would pass in those options.
The docs give an example of auto height calculation for the image:
ws.capture "http://www.google.com/", "google.png", width: 1024
However, webshot's default thumbnail settings produce an image that's only 90 pixels high due to the image processing step within the lib.
There's a workaround as follows for now (override the defaults with an empty imagemagick config):
ws.capture("http://www.bbc.co.uk/news", image_path, width: 1280, timeout: 2) do |magick|
magick.combine_options do |c|
end
end
Not sure what the right approach for a fix is, perhaps not setting a default extent within webshot?
Is it possible to have a configuration option to enable taking a screenshot when there's a 4xx response code? I see at the moment webshot only takes a screenshot with a 200 or 3xx response code otherwise it throws an error.
Thanks for a great gem! I used it to fetch images of thousands of sites. But for some sites it always returns the following error:
Webshot::Screenshot.instance.capture("http://bitcoinplanet.yolasite.com/", "/tmp/thumb.png")
MiniMagick::Error: Command ("identify -quiet -ping /tmp/mini_magick20140924-2486-17g09z6.png") failed: {:status_code=>1, :output=>"identify.im6: improper image header `/tmp/mini_magick20140924-2486-17g09z6.png' @ error/png.c/ReadPNGImage/3675.\n"}
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:381:in `run'
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:363:in `run_command'
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:171:in `valid?'
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:140:in `create'
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:48:in `read'
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:111:in `block in open'
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
from <...>/bundle/ruby/2.0.0/gems/mini_magick-3.7.0/lib/mini_magick/image.rb:110:in `open'
from <...>/bundle/ruby/2.0.0/gems/webshot-0.0.7/lib/webshot/screenshot.rb:56:in `capture'
from (irb):2
from <...>/bundle/ruby/2.0.0/gems/railties-3.2.19/lib/rails/commands/console.rb:47:in `start'
from <...>/bundle/ruby/2.0.0/gems/railties-3.2.19/lib/rails/commands/console.rb:8:in `start'
from <...>/bundle/ruby/2.0.0/gems/railties-3.2.19/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ruby 2.0
phantomjs 1.9.7
webshot 0.0.7
capybara 2.4.3
poltergeist 1.5.1
ubuntu 14.04.1 LTS
Is there any way to configure minimagick so that it crops the webpage image to the height of the webpage, rather than specifying an exact height?
Good morning,
I have a issue with the webshot.
I'm running the project in my local machine. I try to take a screenshot from my webpage, it gives my a time out from the poltergeist. If I try to take a the same page screenshot from the same page, but in some associate instance, doesn't give me the time out.
I look for the answer in other forums and nothing.
Can someone help me please?
I'm using Poltergeist, Capybara and PhantomJS
Hi,
poltergeist gem version 1.8.0 solved some important bugs regarding an out-of-sync on responses.
I'm referring (for example) to these:
teampoltergeist/poltergeist#683
teampoltergeist/poltergeist#482
Is there any chance the dependency on webshot can be updated to version 1.8.0?
Thanks in advance,
Mattia
I am getting the error:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details). ReferenceError: Can't find variable: org ReferenceError: Can't find variable: org at https://www.tradview.com/static/js/chatclient_widget.c001027b8.js:4358
Is it possible to somehow ignore it?
I am using a newer version of mini_magick. I get this error:
Bundler could not find compatible versions for gem "mini_magick":
In snapshot (Gemfile.lock):
mini_magick (= 4.6.1)
In Gemfile:
mini_magick (>= 4.6.1, ~> 4.6)
webshot (~> 0.1.0) was resolved to 0.1.0, which depends on
mini_magick (~> 4.3.3)
Attempting to take a screenshot of a local HTML file results in an error:
Webshot::WebshotError: Could not fetch page: "/var/folders/[REDACTED]/index.html", error code:
Using file:///var/folders/...
does not change anything.
Is there a way to take screenshots of local content without having to run a HTTP server?
Cliver::Dependency::VersionMismatch: Could not find an executable 'phantomjs' that matched the requirements '~> 1.8', '>= 1.8.1'. Found versions were {"/usr/local/bin/phantomjs"=>"2.0.0"}.
Dineshs-MacBook-Pro:My scripts dinesh$ ruby Screenshot\ taker.rb
/Users/dinesh/.rvm/gems/ruby-2.3.1/gems/webshot-0.1.0/lib/webshot/screenshot.rb:95:in rescue in capture': Capybara error: "Request to 'http://auth.indeed.com' failed to reach server, check DNS and/or server status" (Webshot::WebshotError) from /Users/dinesh/.rvm/gems/ruby-2.3.1/gems/webshot-0.1.0/lib/webshot/screenshot.rb:37:in
capture'
from Screenshot taker.rb:11:in block in <main>' from Screenshot taker.rb:5:in
each_line'
from Screenshot taker.rb:5:in `
@vitalie I have an issue to capture the screen from redirected url. Here is my case: I have plan to capture an url and it also takes us to another url. I see it works well on local machine and capture the destination screen successfully. But when I pushed to server (using heroku) and after I entered the url, the screenshot was not captured immediately. The fact is that there is a timeout to capture screen, I mean I should set timeout about 10s to wait the page loaded and it will be captured exactly. Why this one run in a different way between local machine and server?
Hey Guys,
I'm running a Micro EC2 instance on AWS using Ubuntu 16.04.2 and while the CSS is loading correctly, the images aren't. I'm almost certain that there are incoming ports that need to be allowed incoming traffic, but don't know which ones without allowing all incoming traffic. Any ideas suggestions as to which ports should be allowed?
Great gem
.
Im using the gem
in my own application and taking screenshots from some pages inside application. Im not interested to take a screenshot of the whole page but only a targeted div
.
Is it possible to Target a div when taking screen shot?
PS: Im not using MiniMagic
and creating the screenshot in my model
Here is my code
class Post < ActiveRecord::Base
# In my Post model
after_save :save_screeshot
def save_screeshot
Dir.mkdir "public/screenshots/#{self.id}"
ws = Webshot::Screenshot.instance
# Customize thumbnail
ws.capture "http://google.com/", "public/screenshots/#{self.id}/screenshot.png", width: 600, height: 315, quality: 100
end
end
I see there is a default width and height for the PhantomJS viewport in the Webshot module. But I can't seem to find a way to configure those parameters before taking a screenshot. The screenshot class is a singleton and I don't know how to properly pass data to the initialize method.
Hi
Is there any way I can capture multiple pages after a session?
ws = Webshot::Screenshot.instance
ws.start_session do
#set session code
end.capture()#array of urls and array of output images.
Or alternatively, using the same session?
Some websites respond to viewport size, pixel ratio, etc. to display various responsive versions of themselves. Is there any way to pass these parameters on to the browser settings? Beyond user_agent:
?
When I tried to take Screenshot of "http://www.ralecon.com/" it is not working properly. i am using phantomjs-2.1.1 version and webshot-0.1.0 version
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.