Skip to content

Commit 1447f5a

Browse files
authored
Merge pull request #146 from aaryanrr/master
Improved the Web Screenshot Feature
2 parents 5eb6521 + d6ec508 commit 1447f5a

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

pywhatkit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pywhatkit.ascii_art import image_to_ascii_art
1212
from pywhatkit.handwriting import text_to_handwriting
1313
from pywhatkit.mail import send_hmail, send_mail
14-
from pywhatkit.misc import info, playonyt, search, show_history
14+
from pywhatkit.misc import info, playonyt, search, show_history, web_screenshot
1515
from pywhatkit.sc import cancel_shutdown, shutdown
1616
from pywhatkit.whats import (
1717
open_web,

pywhatkit/misc.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import time
23
import webbrowser as web
34
from platform import system
@@ -18,16 +19,25 @@ def take_screenshot(
1819
screen = ImageGrab.grab()
1920
screen.show(title=file_name)
2021
screen.save(f"{file_name}.png")
21-
def web_scr(link:str) -> None:
22-
BASE = 'https://render-tron.appspot.com/screenshot/'
23-
url = link
24-
path = 'ScreenShot.jpg'
25-
response = requests.get(BASE + url, stream=True)
22+
23+
24+
def web_screenshot(
25+
link: str,
26+
filename: str = "Screenshot.jpg",
27+
path: str = os.getcwd(),
28+
width: int = 1920,
29+
height: int = 1080,
30+
) -> None:
31+
"""Take Screenshot of Any Website Without Opening it"""
32+
33+
url = f"https://render-tron.appspot.com/screenshot/{link}/?width={width}&height={height}"
34+
response = requests.get(url, stream=True)
2635
if response.status_code == 200:
27-
with open(path, 'wb') as file:
36+
with open(os.path.join(path, filename), "wb") as file:
2837
for chunk in response:
2938
file.write(chunk)
3039

40+
3141
def show_history() -> None:
3242
"""Prints the Log File Generated by the Library"""
3343

0 commit comments

Comments
 (0)