kmisc 2.1.119__py3-none-any.whl → 2.1.120__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kmisc/__init__.py +45 -0
- {kmisc-2.1.119.dist-info → kmisc-2.1.120.dist-info}/METADATA +1 -1
- kmisc-2.1.120.dist-info/RECORD +6 -0
- kmisc-2.1.119.dist-info/RECORD +0 -6
- {kmisc-2.1.119.dist-info → kmisc-2.1.120.dist-info}/LICENSE +0 -0
- {kmisc-2.1.119.dist-info → kmisc-2.1.120.dist-info}/WHEEL +0 -0
- {kmisc-2.1.119.dist-info → kmisc-2.1.120.dist-info}/top_level.txt +0 -0
kmisc/__init__.py
CHANGED
@@ -3447,6 +3447,51 @@ def Upper(src,default='org'):
|
|
3447
3447
|
if isinstance(src,str): return src.upper()
|
3448
3448
|
if default in ['org',{'org'}]: return src
|
3449
3449
|
return default
|
3450
|
+
|
3451
|
+
def web_capture(url,output_file,image_size='1920,1080',wait_time=3):
|
3452
|
+
if isinstance(image_size,str):
|
3453
|
+
if 'x' in image_size:
|
3454
|
+
image_size=image_size.split('x')
|
3455
|
+
elif ',' in image_size:
|
3456
|
+
image_size=image_size.split(',')
|
3457
|
+
if isinstance(image_size,(list,tuple)) and len(image_size) == 2:
|
3458
|
+
image_size=','.join([str(i) for i in image_size])
|
3459
|
+
else:
|
3460
|
+
#Set it to default image size
|
3461
|
+
image_size='1920,1080'
|
3462
|
+
|
3463
|
+
if Import('import selenium'):
|
3464
|
+
return False,'Can not install selenium package'
|
3465
|
+
else:
|
3466
|
+
# Configure Chrome options for headless mode
|
3467
|
+
from selenium.webdriver.chrome.options import Options
|
3468
|
+
chrome_options = Options()
|
3469
|
+
chrome_options.add_argument('--headless') # Run in headless mode
|
3470
|
+
chrome_options.add_argument('--no-sandbox')
|
3471
|
+
chrome_options.add_argument('--disable-dev-shm-usage')
|
3472
|
+
chrome_options.add_argument(f"--window-size={image_size}") # Set window size
|
3473
|
+
# Initialize the Chrome driver
|
3474
|
+
driver = selenium.webdriver.Chrome(options=chrome_options)
|
3475
|
+
rc=False,output_file
|
3476
|
+
try:
|
3477
|
+
# Navigate to the URL
|
3478
|
+
driver.get(url)
|
3479
|
+
|
3480
|
+
# Wait for the page to load
|
3481
|
+
time.sleep(wait_time)
|
3482
|
+
|
3483
|
+
# Capture screenshot
|
3484
|
+
driver.save_screenshot(output_file)
|
3485
|
+
#print(f"Screenshot saved to {output_file}")
|
3486
|
+
rc=True,output_file
|
3487
|
+
except Exception as e:
|
3488
|
+
#print(f"Error capturing screenshot: {str(e)}")
|
3489
|
+
rc=False,str(e)
|
3490
|
+
finally:
|
3491
|
+
# Close the browser
|
3492
|
+
driver.quit()
|
3493
|
+
return rc
|
3494
|
+
|
3450
3495
|
############################################
|
3451
3496
|
#Temporary function map for replacement
|
3452
3497
|
############################################
|
@@ -0,0 +1,6 @@
|
|
1
|
+
kmisc/__init__.py,sha256=Qohn7dgINzBWEjZdl2wfKfd8BA1hlRU3aJqTrZODRok,146663
|
2
|
+
kmisc-2.1.120.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
+
kmisc-2.1.120.dist-info/METADATA,sha256=hdsc0wTLXtmnsiy-gE1iHYnABkJwT1fy3oGbH44tbm8,5523
|
4
|
+
kmisc-2.1.120.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
5
|
+
kmisc-2.1.120.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
+
kmisc-2.1.120.dist-info/RECORD,,
|
kmisc-2.1.119.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
kmisc/__init__.py,sha256=y5Zhnl1MrphTwpiFDDqb1Wik16xRMSVa-E245qIvgyQ,144993
|
2
|
-
kmisc-2.1.119.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
-
kmisc-2.1.119.dist-info/METADATA,sha256=xSeiDK45vbXDx2QUB1aWT4KhKScIJwPcd683w8ZoiX8,5523
|
4
|
-
kmisc-2.1.119.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
5
|
-
kmisc-2.1.119.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
-
kmisc-2.1.119.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|