Skip to content

Commit 64ca517

Browse files
committed
✨ More Options for the Web Screenshot
1 parent 0c8e500 commit 64ca517

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

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 = 1613,
29+
height: int = 786,
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)