0% found this document useful (0 votes)
5 views3 pages

message (1)

The document is a Python script that interacts with the Intelx API to search for information based on a provided ID. It includes error handling for various HTTP responses and allows users to save the search results to a specified file path. The script also features a user-friendly interface with colored text output and prompts for user input.

Uploaded by

binro01120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

message (1)

The document is a Python script that interacts with the Intelx API to search for information based on a provided ID. It includes error handling for various HTTP responses and allows users to save the search results to a specified file path. The script also features a user-friendly interface with colored text output and prompts for user input.

Uploaded by

binro01120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import requests

import time
from bs4 import BeautifulSoup
from termcolor import colored
import os
import subprocess

if os.name == 'nt':
os.system('')

def print_blue_text(text):
print(colored(text, 'blue', attrs=['bold']))

class Intelx:
API_ROOT = 'https://intelx.io/'
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"

def __init__(self, api_key):


self.API_KEY = api_key

def search_intelx_by_id(self, did):


url = f"{self.API_ROOT}?did={did}"
headers = {
"User-Agent": self.USER_AGENT,
"x-key": self.API_KEY
}

try:
response = requests.get(url, headers=headers)
response.raise_for_status()
except requests.exceptions.HTTPError as errh:
if response.status_code == 400:
print("Requête incorrecte ou invalide.")
elif response.status_code == 401:
print("Authentification échouée.")
elif response.status_code == 403:
print("Accès refusé.")
elif response.status_code == 404:
print("ID non trouvé.")
elif response.status_code == 429:
print("Nombre maximal de requêtes autorisées dépassé. Attendez
avant de réessayer.")
elif response.status_code == 500:
print("Erreur interne sur le serveur. Contactez l'administrateur
pour plus d'informations.")
elif response.status_code == 503:
print("Serveur temporairement indisponible. Réessayez plus tard.")
else:
print("Erreur HTTP inconnue.")
return None
except requests.exceptions.ConnectionError as errc:
print("Erreur de connexion :", errc)
return None
except requests.exceptions.Timeout as errt:
print("Erreur de timeout :", errt)
return None
except requests.exceptions.RequestException as err:
print("Erreur de requête :", err)
return None

if response.status_code == 200:
return response.text
else:
print("Erreur :", response.status_code)
return None

def main():
print_blue_text(r" /$$ /$$ /$$
")
time.sleep(0.1)
print_blue_text(r" | $$ | $$ | $$
")
time.sleep(0.1)
print_blue_text(r" /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ | $$$$$$$ /$$$$$$
/$$$$$$$ /$$$$$$ ")
time.sleep(0.1)
print_blue_text(r" /$$__ $$ |____ $$|_ $$_/ |____ $$| $$__ $$ |____ $
$ /$$_____/ /$$__ $$")
time.sleep(0.1)
print_blue_text(r"| $$ | $$ /$$$$$$$ | $$ /$$$$$$$| $$ \ $$ /$$$$$$$|
$$$$$$ | $$$$$$$$")
time.sleep(0.1)
print_blue_text(r"| $$ | $$ /$$__ $$ | $$ /$$ /$$__ $$| $$ | $$ /$$__ $
$ \____ $$| $$_____/")
time.sleep(0.1)
print_blue_text(r"| $$$$$$$| $$$$$$$ | $$$$/| $$$$$$$| $$$$$$$/| $$$$$$
$ /$$$$$$$/| $$$$$$$")
time.sleep(0.1)
print_blue_text(r" \_______/ \_______/ \___/ \_______/|_______/ \_______/|
_______/ \_______/")
time.sleep(0.1)
print_blue_text("Made by discord.gg/database")

api_key = input("API key : ")


intelx_client = Intelx(api_key)

while True:
did = input("ID (did=...) de l'URL ou tapez 'exit' pour quitter : ")
if did.lower() == "exit":
break

print("\nRecherche en cours...\n")

result = intelx_client.search_intelx_by_id(did)

if result:
soup = BeautifulSoup(result, 'html.parser')
paragraphs = soup.find_all('p')
for paragraph in paragraphs:
print(paragraph.text)

attempts = 0
while attempts < 3:
file_path = input("Entrez le chemin du fichier pour enregistrer le
résultat de la recherche : ")
if os.path.exists(file_path):
with open(f"{file_path}\\{did}.txt", "w", encoding="utf-8") as
file:
file.write(result)
print(f"Résultat de la recherche enregistré dans {file_path}\\
{did}.txt")
break
else:
print("Chemin de fichier invalide. Veuillez entrer un chemin de
fichier valide.")
attempts += 1
else:
print("Erreur : trop de tentatives échouées. Passage à la suite.")
else:
print("Aucun résultat trouvé.")

if __name__ == "__main__":
main()

You might also like