'how to take screenshot of youtube page without opening the browser in python or R?
I want to take screenshot of several links belonging to youtube. I want to take screenshot of the webpage where it will play the video and then take screenshot or take the screenshot without playing but all this has to happen using python or R but they shouldn't open the browser. it should all happen in the backend.
Any help on this will be great.
Thank you in advance.
I have tried opening the link and taking the screenshot using both R and python and it does take the screenshot without opening browser. But the video screenshot is black with an error which I don't want.
code in R library(webshot) webshot("https://www.youtube.com/watch?v=Nym5stAJAt8","test.png")
code in python from selenium import webdriver driver=webdriver.PhantomJS() driver.set_window_size(1120, 550) driver.get("https://www.youtube.com/watch?v=Nym5stAJAt8") driver.save_screenshot("screenshot.png")
Solution 1:[1]
This maybe is related to the following factors:
Run your code from the command line or automatically schedule your code in the background.
The type and driver of video graphic card of your running machine.
For 1) I always can get the right capture pictures if I start my code from windows10 command line. If it is scheduled from the background, it may not be successful.
For 2) I tried to schedule on backend screenshot of my machine's win10 desktop through the libraries 'pywin32' and 'pyscreenshot' of Python. The result: some of my machines worked well, while some failed in all the black screenshots.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | James Wang |
