Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Harendra Kumar Kanojiya harendra21

🏠
Working from home
View GitHub Profile
View scrap-img.py
from selenium import webdriver
import requests as rq
import os
from bs4 import BeautifulSoup
import time
# path= E:\web scraping\chromedriver_win32\chromedriver.exe
path = input("Enter Path : ")
url = input("Enter URL : ")
View battery-notifire.py
# pip install psutil
import psutil
battery = psutil.sensors_battery()
plugged = battery.power_plugged
percent = battery.percent
if percent <= 30 and plugged!=True:
# pip install py-notifier
View age-calculator.py
# -*- coding: utf-8 -*-
import time
from calendar import isleap
# judge the leap year
def judge_leap_year(year):
if isleap(year):
return True
else:
return False
View file-sorter.py
import os
import shutil
os.chdir("E:\downloads")
#print(os.getcwd())
#check number of files in directory
files = os.listdir()
#list of extension (You can add more if you want)
extentions = {
View send-mail-bulk.py
import csv
from email.message import EmailMessage
import smtplib
def get_credentials(filepath):
with open("credentials.txt", "r") as f:
email_address = f.readline()
email_pass = f.readline()
return (email_address, email_pass)
View convert-pdf-to-audio-script-in-python.md

How to convert PDF to Audio using Python

import pyttsx3
import PyPDF2
pdfreader = PyPDF2.PdfFileReader(open('story.pdf','rb'))
speaker = pyttsx3.init()
for page_num in range(pdfreader.numPages):   
    text = pdfreader.getPage(page_num).extractText()  ## extracting text from the PDF
    cleaned_text = text.strip().replace('\n',' ')  ## Removes unnecessary spaces and break lines
    print(cleaned_text)                ## Print the text from PDF
View pdf-to-audio.py
# Python script to PDF to Audio
import pyttsx3
import PyPDF2
pdfreader = PyPDF2.PdfFileReader(open('story.pdf','rb'))
speaker = pyttsx3.init()
for page_num in range(pdfreader.numPages):
text = pdfreader.getPage(page_num).extractText() ## extracting text from the PDF
cleaned_text = text.strip().replace('\n',' ') ## Removes unnecessary spaces and break lines
print(cleaned_text) ## Print the text from PDF
#speaker.say(cleaned_text) ## Let The Speaker Speak The Text
View receive-gmail-emails.py
import email
import python-imap
EMAIL = 'mymail@mail.com'
PASSWORD = 'password'
SERVER = 'imap.gmail.com'
# connect to the server and go to its inbox
mail = imaplib.IMAP4_SSL(SERVER)
mail.login(EMAIL, PASSWORD)
View medium-twitter-bot.py
# post - https://medium.com/p/889e37c71c4e
import tweepy
import urllib
from urllib.request import urlretrieve
from urllib.parse import urlparse
import os
import requests
# Twitter keys - https://developer.twitter.com/
API_KEY = "token_here"
View python-music-player.py
import pygame
from pygame import mixer
from tkinter import *
import os
def playsong():
currentsong=playlist.get(ACTIVE)
print(currentsong)
mixer.music.load(currentsong)
songstatus.set("Playing")