Skip to content

Instantly share code, notes, and snippets.

View makesomelayouts's full-sized avatar
🏠
Working from home

msl makesomelayouts

🏠
Working from home
View GitHub Profile
from pytube import YouTube
if __name__ == '__main__':
links = [
# 'https://www.youtube.com/shorts/klmBTGQUkbM', 'https://www.youtube.com/watch?v=hS5CfP8n_js'
'https://www.youtube.com/watch?v=unUaqMJA9D0'
]
counter = 0
import requests
with open('proxies.txt') as f:
proxies = f.read().split('\n')
""" or!
proxies = f.readlines()
proxies = [proxy.strip() for proxy in proxies]
"""
working_proxies = []
import requests
from fake_useragent import UserAgent
response = requests.get('https://httpbin.org/get', headers={'user-agent': UserAgent().random})
print(response.status_code)
print(f'response.content={response.content}\n')
# Converting a list of strings to a list of integers
numbers = ['1', '2', '3', '4', '5']
result = list(map(int, numbers))
print(result) # [1, 2, 3, 4, 5]
# Multiplying each element of a list by 2
numbers = [1, 2, 3, 4, 5]
result = list(map(lambda x: x*2, numbers))
print(result) # [2, 4, 6, 8, 10]
import csv
import re
from collections import Counter
# for find ip's that DDoS server in local log.txt file
def reader(filename):
regexp = r'\d{1, 3}\.\d{1,3}\.d{1,3}' # \d = 0-9 ;; \d{1, 3} = 1-3
from difflib import SequenceMatcher
def Plagiarism_checker(f1, f2):
with open(f1, errors='ignore') as file1, open(f2, errors='ignore') as file2:
f1_data = file1.read()
f2_data = file2.read()
checking = SequenceMatcher(None, f1_data, f2_data).ratio()
print(f'These files are {checking * 100} % similar')
a, b = 1092, 1092; c = 1092
print(a is b is c) # True
a, b = 1092, 1092
c = 1092
print(a is b, a is c) # True, False
# but
a, b = 92, 92
@makesomelayouts
makesomelayouts / soup select vs soup find.txt
Created January 28, 2023 07:07
soup select vs soup find
soup = BeautifulSoup(src, 'lxml')
soup.select('.mzr-tc-group-table tr th')
# ==
soup.find(class_='mzr-tc-group-table').find('tr').find_all('th')
@makesomelayouts
makesomelayouts / file manipulation in python.txt
Last active November 6, 2025 06:21
file manipulation in python
options:
r=read,
w=write (change old data to new data),
rb/wb=read/write-binaryy (for binary files),
a=append(add new data to old data).
@makesomelayouts
makesomelayouts / folder_content.py
Last active February 2, 2023 21:41
prints what is contained in the folder
import os
def main():
i = 0
source_dir = input('folder path: ')
with os.scandir(source_dir) as entries:
for entry in entries:
i += 1
print(f'{i} :: {entry.name}')