Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Hazrat Ali coding-with-ali

🎯
Focusing
View GitHub Profile
@coding-with-ali
coding-with-ali / remove-similiar-files.py
Created Jul 3, 2022
Delete all similiar files from a directory and sub directory in python
View remove-similiar-files.py
import os
def get_filepaths(directory):
file_paths = [] # List which will store all of the full filepaths.
# Walk the tree.
for root, directories, files in os.walk(directory):
for filename in files:
# Join the two strings in order to form the full filepath.
@coding-with-ali
coding-with-ali / scrape-imdb.py
Created Apr 21, 2022
web scrapping with requests-html in python
View scrape-imdb.py
from requests_html import HTMLSession
session = HTMLSession()
url = "https://www.imdb.com/chart/top/?ref_=nv_mv_250"
response = session.get(url)
titles_es=response.html.find('.titleColumn')
for movie_title in titles_es:
print(movie_title.text)
@coding-with-ali
coding-with-ali / glob-example.py
Created Apr 20, 2022
search for all .py files inside a directory. It will find all python files available in subdirectores. It will search recursively. we have used glob module.
View glob-example.py
# author AlixaProDev
import glob
# path of the current directory
path = './'
curfiles = glob.glob(path + '**/*.py',recursive=True)
for file in curfiles:
print(file)
@coding-with-ali
coding-with-ali / alarm.py
Last active Mar 9, 2022
alarm.py is a simple alarm with python and tkinter.
View alarm.py
'''
@author : alixaprodev.com
'''
from tkinter import *
import datetime
import time
import winsound
from threading import *
root = Tk()
root.geometry("400x200")
View grab h4 tag with bs4.py
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
url = 'https://www.amazon.com/s?k=python+books&ref=nb_sb_noss_2'
response = requests.get(url)
htmldata = BeautifulSoup(response.text, "html.parser")
print(htmldata)
h4tags=htmldata.findall('h4')
@coding-with-ali
coding-with-ali / spider.py
Created Dec 5, 2021
scrape website using python
View spider.py
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
url = 'https://www.amazon.com/s?k=python+books&ref=nb_sb_noss_2'
response = requests.get(url)
htmldata = BeautifulSoup(response.text, "html.parser")
print(htmldata)