inital commit
This commit is contained in:
24
scrapper/Basic/add_remove_text.py
Normal file
24
scrapper/Basic/add_remove_text.py
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
def remove_and_insert_text(text_to_remove):
|
||||
|
||||
source_file = 'proxies.txt'
|
||||
destination_file = "proxies_block_ips.txt"
|
||||
|
||||
|
||||
with open(destination_file, 'a') as file:
|
||||
file.write('\n' + text_to_remove)
|
||||
|
||||
|
||||
with open(source_file, 'r') as file:
|
||||
content = file.read()
|
||||
|
||||
|
||||
if text_to_remove in content:
|
||||
|
||||
modified_content = content.replace(text_to_remove, '')
|
||||
cleaned_content = '\n'.join(line.strip() for line in modified_content.splitlines() if line.strip())
|
||||
|
||||
with open(source_file, 'w') as file:
|
||||
file.write(cleaned_content)
|
||||
else:
|
||||
print("remove text not found")
|
||||
27
scrapper/Basic/helper.py
Normal file
27
scrapper/Basic/helper.py
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
from datetime import datetime
|
||||
import requests
|
||||
|
||||
|
||||
def check_access_denied(url):
|
||||
try:
|
||||
response = requests.get(url)
|
||||
|
||||
return response.status_code
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
return f"Error: {e}"
|
||||
|
||||
|
||||
def get_current_datetime():
|
||||
now = datetime.now()
|
||||
formatted_time = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
return formatted_time
|
||||
|
||||
|
||||
def read_proxies():
|
||||
all_proxies = []
|
||||
with open('proxies.txt', 'r') as file:
|
||||
for line in file:
|
||||
all_proxies.append(line.strip())
|
||||
return all_proxies
|
||||
29
scrapper/Basic/log_manager.py
Normal file
29
scrapper/Basic/log_manager.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
import os
|
||||
|
||||
|
||||
def get_logging():
|
||||
|
||||
log_dir = 'logs'
|
||||
if not os.path.exists(log_dir):
|
||||
os.makedirs(log_dir)
|
||||
|
||||
|
||||
date_str = datetime.now().strftime('%Y-%m-%d')
|
||||
|
||||
|
||||
log_filename = os.path.join(log_dir, f'app_{date_str}.log')
|
||||
|
||||
|
||||
if not os.path.exists(log_filename):
|
||||
|
||||
logging.basicConfig(filename=log_filename, filemode='w', level=logging.ERROR,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
else:
|
||||
|
||||
logging.basicConfig(filename=log_filename, filemode='a', level=logging.ERROR,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
return logging
|
||||
|
||||
42
scrapper/Basic/send_email.py
Normal file
42
scrapper/Basic/send_email.py
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
|
||||
def send_email(subject,message):
|
||||
print('-- Email Sending --')
|
||||
# Configuration
|
||||
port = 587
|
||||
smtp_server = "smtp.gmail.com"
|
||||
login = "noreply.readytogoletters@gmail.com" # Your login generated by Mailtrap
|
||||
password = "fymebmopnajzwkfb"
|
||||
sender_email = "test.velocity@gmail.com"
|
||||
|
||||
# port = 587
|
||||
# smtp_server = "sandbox.smtp.mailtrap.io"
|
||||
# login = "b879299bf7dd9a"
|
||||
# password = "3c1ee98e9ddeb7"
|
||||
# sender_email = "pulak.deb@softrobotics.com.bd"
|
||||
|
||||
|
||||
|
||||
# List of recipient email addresses
|
||||
receiver_emails = ["rajibcuetcse@gmail.com","bpulakd@gmail.com"]
|
||||
#receiver_emails = ["bpulakd@gmail.com"]
|
||||
|
||||
text = f"{message}"
|
||||
|
||||
message = MIMEText(text, "plain") # Create MIMEText object
|
||||
message["Subject"] = subject
|
||||
message["From"] = sender_email
|
||||
message["To"] = ", ".join(receiver_emails) # Join the list of receiver emails into a string separated by commas
|
||||
|
||||
# Send the email
|
||||
with smtplib.SMTP(smtp_server, port) as server:
|
||||
server.starttls() # Secure the connection
|
||||
server.login(login, password)
|
||||
# Loop through each recipient and send the email individually
|
||||
for recipient in receiver_emails:
|
||||
server.sendmail(sender_email, recipient, message.as_string())
|
||||
|
||||
print('Sent')
|
||||
Reference in New Issue
Block a user