from bs4 import BeautifulSoup import requests url = 'https://www.python.org/' reqs = requests.get(url) soup = BeautifulSoup(reqs.text, 'html.parser') for link in soup.find_all('a'): print(link.get('href'))
import os folder_path = '/path/to/folder' for filename in os.listdir(folder_path): os.rename(os.path.join(folder_path, filename), os.path.join(folder_path, filename.replace(" ", "_")))
2. File Renaming
3. Automated Email Sending
import smtplib server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login("your_email", "your_password") msg = "Hello, this is a test email!" server.sendmail("your_email", "recipient_email", msg) server.quit()
4. Data Extraction from Excel
5. Automated Web Browsing
import smtplib server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login("your_email", "your_password") msg = "Hello, this is a test email!" server.sendmail("your_email", "recipient_email", msg) server.quit()
6. Automated Tweeting
import tweepy consumer_key = 'your_key' consumer_secret = 'your_secret' access_token = 'your_token' access_token_secret = 'your_token_secret' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) api.update_status('Hello, this is a test tweet from Python!')