Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
screenshot
#1
I want to take picture from page in different size(picture must be responsive)
i do not want use api.
the api that there is in this site(https://www.site-shot.com/) is good ,and i want to use code that work same.
Reply
#2
And your question is? You want to write code that do the same? You want to use their API? Something else?
What have you tried so far? Post your code in python tags, full traceback - if you get one - in error tags.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
yes,i want to write code to take picture from page in define size.(mobile size and desktop size)

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

# Provide a list of urls to create screenshots from
link = 'http://digikala.com'

# The Chrome and ChromeDriver Paths will vary based on your Operating System.
# This example shows how to configure ChromeDriver for Mac
CHROME_PATH = '/usr/bin/google-chrome-stable'
CHROMEDRIVER_PATH = '/home/arezoo/Desktop/chromedriver'

# Set the Browser Size
WINDOW_SIZE = "320,480"

# Configure Chrome Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
chrome_options.binary_location = CHROME_PATH

driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH,
                          options=chrome_options)

# Loop through the list of urls and save the screenshot

driver.get(link)

# sleep for 2 seconds to allow the page to fully load.
time.sleep(2)

# create a clean filename from the url
str = link.split('://')[1]
filename = str.replace('/', '__')
image = filename.replace('.', '_') + ".png"

# save the screenshot
driver.save_screenshot(image)

# Close Selenium
driver.close()
Reply
#4
If you continue like this, it will be very difficult to get real help. What is the problem with that code? Describe your specific problem and ask specific questions...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Taking screenshot ConsistentlyInconsistent 1 1,090 Sep-10-2023, 11:20 PM
Last Post: Larz60+
  Flask Can't Save Screenshot to Postgres Db firebird 3 2,378 Sep-21-2020, 09:22 PM
Last Post: firebird
  Store Screenshot Selenium + MongoDB Nuwan16 9 3,600 Aug-18-2020, 03:57 AM
Last Post: ndc85430
  Screenshot web page ! ABVSVL 3 3,325 Jul-11-2020, 01:39 PM
Last Post: snippsat
  selenium screenshot hai001 18 13,962 Feb-25-2017, 06:22 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020