Skip to content

Instantly share code, notes, and snippets.

from bs4 import BeautifulSoup
import requests
import re
search_term = input("What product do you want to search for? ")
url = f"https://www.newegg.ca/p/pl?d={search_term}&N=4131"
page = requests.get(url).text
doc = BeautifulSoup(page, "html.parser")
@TheSkyFox3006
TheSkyFox3006 / dbapi.py
Created August 21, 2021 19:30
Accessing databases with Python
from dbmodule import connect
#create connection with object
connection = connect('databasename','username','password')
#create a cursor object
cursor = connection.cursor()
#Run queries
cursor.execute('select * from mytable')
import random, string
def password(length, num=false,strength='weak'):
"""length of password, num if you want a number and strength(weak, strong,very)"""
lower = string.ascii_lowercase
upper = string.ascii_uppercase
letter = lower + upper
dig = string.digits
punct = string.punctuation
pwd = ' '
@TheSkyFox3006
TheSkyFox3006 / PDF_to_audiobook.py
Last active September 17, 2020 20:43
Converting PDFs into an audiobook
import pyttsx3
import PyPDF2
pdf_book = open('book.pdf','rb')
pdf_book_reader = PyPDF2.PdfFileReader(pdf_book)
pages_no = pdf_book_reader.numPages
print(pages_no)
speaker = pyttsx3.init()
for number in range(8,pages_no):
page_start = pdf_book_reader.getPage(8)
text = page_start.extractText()
@TheSkyFox3006
TheSkyFox3006 / EDA_titanic.py
Last active October 16, 2020 00:21
Exploratory Data Analysis(EDA)
#Install all the below mention librarie before using pandas-profiling
import pandas as pd
import numpy as np
from pandas_profiling import ProfileReport
#EDA using pandas-profiling
profile = ProfileReport(pd.read_csv('titanic.csv'),title='Pandas Profiling Report',html={'style': {'full_width': True}}, sort="None"))
#to view result in jupyter notebook or google colab
profile.to_widgets()