pip install requests bs4
import reimport requestsfrom bs4 import BeautifulSoup url = "https://www.youtube.com/@SanthoshBalajiRamesh" # Headers with Accept-Language set to en-USheaders = { "Accept-Language": "en-US,en;q=0.9"}soup = BeautifulSoup(requests.get(url, headers=headers).content, "html.parser") # print(soup.prettify()) # Use regex to find the numbermatch = re.search(r'"content":\s*"\b([\d.]+[MK]?)\b\s*subscribers"', soup.prettify()) if match: subscriber_count = match.group(1) print("Subscriber Count:", subscriber_count)else: print("Subscriber count not found!")
import shutilimport requestsfrom pathlib import Pathfrom bs4 import BeautifulSoupfrom urllib.parse import urljoin # Function to get the safe URL from an img tag's srcdef get_safe_url(src, base_url): if src.startswith("/"): return urljoin(base_url, src) elif not src.startswith(("http://", "https://")): return f"https://{src}" return src # Fetch the webpage contentbase_url = "https://santhosh2r2.github.io"url = base_url +"/youtube/blog/vagrant-migration" #base_url = "https://google.de"#url = base_url +"/" # Destination folderdestination_folder = Path("img")if destination_folder.exists(): shutil.rmtree(destination_folder)destination_folder.mkdir(parents=True, exist_ok=True) response = requests.get(url)soup = BeautifulSoup(response.content, "html.parser") # Iterate over all img tags and download imagesfor i, img in enumerate(soup.find_all("img")): img_src = img.get("src") # Ignoring "src" which starts with "data", # incase of svg or base64 encoded string if not img_src.startswith("data"): safe_url = get_safe_url(img_src, base_url) img_data = requests.get(safe_url).content filename = Path(img_src).name with open(destination_folder / filename, 'wb') as file: file.write(img_data) print(img_src) print("Images downloaded successfully.")
pip install Pillow
from PIL import Imageimport os def images_to_pdf(image_folder, output_pdf): image_list = [] for file_name in os.listdir(image_folder): if file_name.endswith((".png", ".jpg", ".jpeg", "gif", "webp")): print(file_name) image_path = os.path.join(image_folder, file_name) image = Image.open(image_path).convert('RGB') image_list.append(image) if image_list: image_list[0].save(output_pdf, save_all=True, append_images=image_list[1:]) print(f"PDF created: {output_pdf}") else: print("No images found.")images_to_pdf("img", "output.pdf")
# pip install pyperclip import pyperclipimport time def log_clipboard(): previous = "" while True: current = pyperclip.paste() if current != previous: with open("output\clipboard_log.txt", "a") as log: log.write(f"{current}\n") previous = current time.sleep(1) log_clipboard()
# pip install plyer import timefrom plyer import notification def break_notifier(): while True: notification.notify( title="Self-Reminder: BREAK TIME", message="Stand up, strech and save your back.", timeout=2 ) time.sleep(5) break_notifier()
import imaplibimport osfrom dotenv import load_dotenv load_dotenv() gmail_user = os.getenv("GMAIL_USER")gmail_password = os.getenv("GMAIL_PASSWORD") def unseen_emails(): mail = imaplib.IMAP4_SSL("imap.gmail.com") mail.login(gmail_user, gmail_password) mail.select("inbox") result, data = mail.search(None, 'UNSEEN') emails = data[0].split() print(f"You have {len(emails)} unread emails.") unseen_emails()
import shutil def check_disk_usage(folder): total, used, free = shutil.disk_usage(folder) print(f"Folder: {folder}, Free Space: {free // (2**30)} GB") check_disk_usage("C:")
# pip install pillow pyautogui import pyautoguiimport time def take_screenshots(): while True: screenshot = pyautogui.screenshot() screenshot.save(f'output\\screenshots\\primary_monitor_{time.time()}.png') print("Screenshot saved.") time.sleep(5) # Every 5 seconds take_screenshots()