Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Harendra Kumar Kanojiya harendra21

🏠
Working from home
View GitHub Profile
View weather.py
# Python program to find current weather details of any city using openweathermap api
import requests
# Enter your API key here
api_key = "Your_API_Key"
# base_url variable to store url
base_url = "http://api.openweathermap.org/data/2.5/weather?"
# Give city name
View check_connection.py
import csv
import requests
status_dict = {"Website": "Status"}
def main():
with open("websites.txt", "r") as fr:
for line in fr:
website = line.strip()
status = requests.get(website).status_code
status_dict[website] = "working" if status == 200 \
View wikipedia.py
from bs4 import BeautifulSoup
import requests
# Trying to open a random wikipedia article
# Special:Random opens random articles
res = requests.get("https://en.wikipedia.org/wiki/Special:Random")
res.raise_for_status()
# pip install htmlparser
wiki = BeautifulSoup(res.text, "html.parser")
View image_converter.py
from PIL import Image
import sys
import os
try:
im = None
for root, dirs, files in os.walk("."):
for filename in files:
if filename.endswith('.jpg'):
im = Image.open(filename).convert("RGB")
View tts.py
from gtts import gTTS
import os
file = open("abc.txt", "r").read()
speech = gTTS(text=file, lang='en', slow=False)
speech.save("voice.mp3")
os.system("voice.mp3")
View youtube_comments.py
from selenium import webdriver
import csv
import time
items=[]
driver=webdriver.Chrome(r"C:/Users/hp/Anaconda3/chromedriver.exe")
driver.get('https://www.youtube.com/watch?v=iFPMz36std4')
driver.execute_script('window.scrollTo(1, 500);')
View imdb.py
from bs4 import BeautifulSoup
import requests
import pandas as pd
import os
# Setting up session
s = requests.session()
# List contaiting all the films for which data has to be scraped from IMDB
films = []
View compress_file.py
import zipfile
import sys
import os
# compress file function
def zip_file(file_path):
compress_file = zipfile.ZipFile(file_path + '.zip', 'w')
compress_file.write(path, compress_type=zipfile.ZIP_DEFLATED)
compress_file.close()
View stopwatch.py
import tkinter as Tkinter
from datetime import datetime
counter = 0
running = False
def counter_label(label):
def count():
if running:
global counter
View arrange-files.py
import os
import glob
import shutil
from os import path
filename=glob.glob("/path/to/folder/*")
documents=['.pdf','.docx','.doc','.txt','.csv','.xlsx','.sql','.json']
pictures=['.jpeg','.jpg','.svg','.png','.PNG','.gif']
videos=['.mp4','.avi','.webm']