Skip to content

Commit

Permalink
Merge pull request #146 from aaryanrr/master
Browse files Browse the repository at this point in the history
Improved the Web Screenshot Feature
  • Loading branch information
aaryanrr authored Nov 14, 2021
2 parents 5eb6521 + d6ec508 commit 1447f5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pywhatkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pywhatkit.ascii_art import image_to_ascii_art
from pywhatkit.handwriting import text_to_handwriting
from pywhatkit.mail import send_hmail, send_mail
from pywhatkit.misc import info, playonyt, search, show_history
from pywhatkit.misc import info, playonyt, search, show_history, web_screenshot
from pywhatkit.sc import cancel_shutdown, shutdown
from pywhatkit.whats import (
open_web,
Expand Down
22 changes: 16 additions & 6 deletions pywhatkit/misc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import time
import webbrowser as web
from platform import system
Expand All @@ -18,16 +19,25 @@ def take_screenshot(
screen = ImageGrab.grab()
screen.show(title=file_name)
screen.save(f"{file_name}.png")
def web_scr(link:str) -> None:
BASE = 'https://render-tron.appspot.com/screenshot/'
url = link
path = 'ScreenShot.jpg'
response = requests.get(BASE + url, stream=True)


def web_screenshot(
link: str,
filename: str = "Screenshot.jpg",
path: str = os.getcwd(),
width: int = 1920,
height: int = 1080,
) -> None:
"""Take Screenshot of Any Website Without Opening it"""

url = f"https://render-tron.appspot.com/screenshot/{link}/?width={width}&height={height}"
response = requests.get(url, stream=True)
if response.status_code == 200:
with open(path, 'wb') as file:
with open(os.path.join(path, filename), "wb") as file:
for chunk in response:
file.write(chunk)


def show_history() -> None:
"""Prints the Log File Generated by the Library"""

Expand Down

0 comments on commit 1447f5a

Please sign in to comment.