ryxme
Master Üye
- Katılım
- 8 Ağu 2024
- Mesajlar
- 933
- Beğeniler
- 175
alın kullanın arkadaşlar isterseniz proxy falan ekleyebilirsiniz txte url ekleyip
Kod:
import asyncio
import aiohttp
import logging
import sqlite3
import csv
import random
from bs4 import BeautifulSoup
from googlesearch import search
from urllib.parse import urlparse, urljoin
from random import choice, randint
from time import sleep
CHECKOUT_METHODS = [
"paypal", "papara", "nuvei", "iyzico", "braintree", "credit card",
"stripe", "kredi kartı", "nuevi", "payment", "3d", "secure payment", "checkout",
"3d secure", "3dsecure", "secure checkout", "3dsecure"
]
EXCLUDED_DOMAINS = [
'github.com', 'reddit.com', 'twitter.com', 'forum', 'hastane', 'intel.com',
'technopat', 'donanimarsivi', 'pchocasi', 'wikipedia', 'trustpilot'
]
NUM_RESULTS = 10
DB_PATH = 'results.db'
PROXY_LIST_URL = 'https://example.com/proxies.txt'
USER_AGENTS = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36",
]
PROXIES = []
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
def init_db():
with sqlite3.connect(DB_PATH) as conn:
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS results (
id INTEGER PRIMARY KEY,
url TEXT NOT NULL,
method TEXT NOT NULL,
found BOOLEAN NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)
''')
conn.commit()
async def fetch(url, session, proxy=None, retries=3):
headers = {'User-Agent': choice(USER_AGENTS)}
for attempt in range(retries):
try:
async with session.get(url, proxy=proxy, headers=headers, timeout=10) as response:
response.raise_for_status()
return await response.text()
except aiohttp.ClientError as e:
logging.error(f"Attempt {attempt + 1} - Error fetching {url}: {e}")
if attempt < retries - 1:
await asyncio.sleep(2 ** attempt)
else:
return None
async def check_checkout_methods(url, session):
content = await fetch(url, session, proxy=choice(PROXIES) if PROXIES else None)
if content:
content_lower = content.lower()
found_methods = [method for method in CHECKOUT_METHODS if method.lower() in content_lower]
for method in CHECKOUT_METHODS:
found = method.lower() in content_lower
save_to_db(url, method, found)
if found_methods:
logging.info(f"Found checkout methods on '{url}': {', '.join(found_methods)}")
else:
logging.info(f"No checkout methods found on '{url}'.")
def save_to_db(url, method, found):
try:
with sqlite3.connect(DB_PATH) as conn:
cursor = conn.cursor()
cursor.execute('''
INSERT INTO results (url, method, found) VALUES (?, ?, ?)
''', (url, method, found))
conn.commit()
except sqlite3.Error as e:
logging.error(f"Database error: {e}")
async def fetch_internal_links(url, session):
internal_links = set()
content = await fetch(url, session)
if content:
soup = BeautifulSoup(content, 'html.parser')
base_url = '/'.join(url.split('/')[:3])
for link in soup.find_all('a', href=True):
href = link['href']
href = urljoin(base_url, href)
if href.startswith(base_url):
internal_links.add(href)
return internal_links
def is_excluded_domain(url):
return any(domain in url for domain in EXCLUDED_DOMAINS)
async def search_google(keywords, num_results):
all_urls = set()
async with aiohttp.ClientSession() as session:
for keyword in keywords:
try:
logging.info(f"Searching for '{keyword}'...")
search_results = search(keyword, num_results=num_results)
all_urls.update(search_results)
await asyncio.sleep(randint(1, 3))
except Exception as e:
logging.error(f"Error during Google search: {e}")
return list(all_urls)
async def run_search(keywords, num_results):
init_db()
urls = await search_google(keywords, num_results)
async with aiohttp.ClientSession() as session:
tasks = []
for url in urls:
if not is_excluded_domain(url):
logging.info(f"Checking '{url}' for checkout methods...")
internal_links = await fetch_internal_links(url, session)
all_links = list(internal_links) + [url]
tasks.extend(check_checkout_methods(link, session) for link in all_links)
random_delay()
await asyncio.gather(*tasks)
def export_to_csv():
try:
with sqlite3.connect(DB_PATH) as conn:
cursor = conn.cursor()
cursor.execute('SELECT * FROM results')
rows = cursor.fetchall()
with open('results.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(['ID', 'URL', 'Method', 'Found', 'Timestamp'])
writer.writerows(rows)
logging.info("Results have been exported successfully.")
except Exception as e:
logging.error(f"Export error: {e}")
async def update_proxies():
global PROXIES
try:
async with aiohttp.ClientSession() as session:
logging.info(f"Updating proxies from {PROXY_LIST_URL}...")
async with session.get(PROXY_LIST_URL) as response:
response.raise_for_status()
proxy_list = await response.text()
proxies = proxy_list.splitlines()
valid_proxies = []
for proxy in proxies:
test_url = 'http://httpbin.org/ip'
content = await fetch(test_url, session, proxy=proxy)
if content:
valid_proxies.append(proxy)
PROXIES = valid_proxies
logging.info("Proxies updated and validated successfully.")
except Exception as e:
logging.error(f"Error updating proxies: {e}")
def random_delay():
delay = randint(1, 3)
logging.info(f"Sleeping for {delay} seconds")
sleep(delay)
if __name__ == "__main__":
try:
use_proxies = input("Do you want to use proxies? (yes/no): ").strip().lower() == 'yes'
if use_proxies:
asyncio.run(update_proxies())
keywords = input("Enter keywords (comma separated): ").split(',')
num_results = int(input("Enter number of results to fetch: "))
asyncio.run(run_search(keywords, num_results))
export_to_csv()
except Exception as e:
logging.error(f"Unexpected error: {e}")