Last active
April 23, 2024 16:06
-
-
Save BesrourMS/639ad93fb71f864a61d470718fa3b272 to your computer and use it in GitHub Desktop.
whois.tn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import json | |
html_content = ''' | |
<div dir="ltr"> | |
<h1>Whois ? : Résultat de la vérification</h1> | |
<p><strong style="color:#C00;">Le nom de domaine kh.tn est déjà enregistré !</strong></p><p></p> | |
<h2><strong>Nom de domaine :</strong> <a href="http://www.kh.tn" target="_blank">kh.tn</a></h2> | |
<h3><p><strong>Détails:</strong></p></h3> | |
<ul><p></p><li><strong>Date création: </strong>13-12-2022 09:49:40 GMT+1</li></ul> | |
<ul><p></p><li><strong>Etat domaine: </strong> Transfert Interdit</li></ul> | |
<ul><p></p><li><strong>Bureau d'Enregistrement: </strong><a href="https://www.oxahost.tn" target="_blank">OXAHOST</a></li></ul> | |
<h3><strong>Titulaire<span class="style3">*</span> :</strong></h3> | |
<ul><p></p><li><strong>Nom : </strong>zaguia</li></ul> | |
<ul><p></p><li><strong>Prenom : </strong>mohamed yassine</li></ul> | |
<ul><p></p><li><strong>Adresse : </strong>ksar hlell</li></ul> | |
<ul><p></p><li><strong>Adresse2 : </strong></li></ul> | |
<ul><p></p><li><strong>Ville : </strong>mounastir</li></ul> | |
<ul><p></p><li><strong>Gouvernorat : </strong>mounastir</li></ul> | |
<ul><p></p><li><strong>Code zip : </strong>5016</li></ul> | |
<ul><p></p><li><strong>Pays : </strong>TN</li></ul> | |
<ul><p></p><li><strong>Tél : </strong>+216.22460000</li></ul> | |
<ul><p></p><li><strong>Fax : </strong></li></ul> | |
<ul><p></p><li><strong>Email : </strong>[email protected]</li></ul> | |
<h3><strong>Contact Administratif<span class="style3">*</span> :</strong></h3> | |
<ul><p></p><li><strong>Nom : </strong>zaguia</li></ul> | |
<ul><p></p><li><strong>Prenom : </strong>mohamed yassine</li></ul> | |
<ul><p></p><li><strong>Adresse : </strong>ksar hlell</li></ul> | |
<ul><p></p><li><strong>Adresse2 : </strong></li></ul> | |
<ul><p></p><li><strong>Ville : </strong>mounastir</li></ul> | |
<ul><p></p><li><strong>Gouvernorat : </strong>mounastir</li></ul> | |
<ul><p></p><li><strong>Code zip : </strong>5016</li></ul> | |
<ul><p></p><li><strong>Pays : </strong>TN</li></ul> | |
<ul><p></p><li><strong>Tél : </strong>+216.22460000</li></ul> | |
<ul><p></p><li><strong>Fax : </strong></li></ul> | |
<ul><p></p><li><strong>Email : </strong>[email protected]</li></ul> | |
<h3><strong>Contact Technique<span class="style3">*</span> :</strong></h3> | |
<ul><p></p><li><strong>Nom : </strong>zaguia</li></ul> | |
<ul><p></p><li><strong>Prenom : </strong>mohamed yassine</li></ul> | |
<ul><p></p><li><strong>Adresse : </strong>ksar hlell</li></ul> | |
<ul><p></p><li><strong>Adresse2 : </strong></li></ul> | |
<ul><p></p><li><strong>Ville : </strong>mounastir</li></ul> | |
<ul><p></p><li><strong>Gouvernorat : </strong>mounastir</li></ul> | |
<ul><p></p><li><strong>Code zip : </strong>5016</li></ul> | |
<ul><p></p><li><strong>Pays : </strong>TN</li></ul> | |
<ul><p></p><li><strong>Tél : </strong>+216.22460000</li></ul> | |
<ul><p></p><li><strong>Fax : </strong></li></ul> | |
<ul><p></p><li><strong>Email : </strong>[email protected]</li></ul> | |
<ul><p></p><li><strong>dnssec : </strong>non signé</li></ul> | |
<h3><strong>Serveurs DNS<span class="style3">*</span> :</strong></h3> | |
<ul><p></p><li><strong>Nom : </strong>ns7.tn.oxa.host.</li></ul> | |
<ul><p></p><li><strong>Nom : </strong>dns7.tn.oxa.host.</li></ul> | |
<ul><p dir="ltr" class="style4">(*) Prière de contacter votre Bureau d'Enregistrement, ci-dessus cité, pour la mise à jour de ces informations.</p><p></p></ul> | |
</div> | |
''' | |
soup = BeautifulSoup(html_content, 'html.parser') | |
whois_result = {} | |
# Extracting domain name and status | |
domain_name = soup.find('a').text | |
domain_status = soup.find('strong', style='color:#C00;').text | |
whois_result['DomainName'] = domain_name | |
whois_result['DomainStatus'] = domain_status | |
# Extracting creation date and domain state | |
details = soup.find_all('ul') | |
creation_date = details[0].li.text.replace('Date création: ', '') | |
domain_state = details[1].li.text.replace('Etat domaine: ', '') | |
whois_result['CreationDate'] = creation_date | |
whois_result['DomainState'] = domain_state | |
# Extracting registrar | |
registrar = details[2].li.a.text | |
whois_result['Registrar'] = registrar | |
# Extracting registrant details | |
registrant_info = details[3:11] | |
registrant = {} | |
for info in registrant_info: | |
key = info.li.strong.text.replace(':', '').strip() | |
value = info.li.text.split(':')[-1].strip() | |
registrant[key] = value | |
whois_result['Registrant'] = registrant | |
# Extracting administrative contact details | |
admin_contact_info = details[11:19] | |
admin_contact = {} | |
for info in admin_contact_info: | |
key = info.li.strong.text.replace(':', '').strip() | |
value = info.li.text.split(':')[-1].strip() | |
admin_contact[key] = value | |
whois_result['AdministrativeContact'] = admin_contact | |
# Extracting technical contact details | |
tech_contact_info = details[19:27] | |
tech_contact = {} | |
for info in tech_contact_info: | |
key = info.li.strong.text.replace(':', '').strip() | |
value = info.li.text.split(':')[-1].strip() | |
tech_contact[key] = value | |
whois_result['TechnicalContact'] = tech_contact | |
# Extracting DNS servers | |
dns_servers = [item.li.text.replace('Nom : ', '') for item in details[-3:-1]] | |
whois_result['DNSServers'] = dns_servers | |
# Extracting DNSSEC status | |
dnssec_status = details[-1].li.text.replace('dnssec : ', '') | |
whois_result['DNSSEC'] = dnssec_status | |
# Convert to JSON | |
json_result = json.dumps({'WhoisResult': whois_result}, indent=2) | |
print(json_result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$curl = curl_init(); | |
curl_setopt_array($curl, [ | |
CURLOPT_URL => "https://whois.ati.tn/", | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_ENCODING => "", | |
CURLOPT_MAXREDIRS => 10, | |
CURLOPT_TIMEOUT => 30, | |
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
CURLOPT_CUSTOMREQUEST => "POST", | |
CURLOPT_POSTFIELDS => "domain=bnb&ext=1&submit=ok&b_existe=Existe%3F", | |
CURLOPT_COOKIE => "PHPSESSID=1oi1k48jki92f6r5lg36cdprv2", | |
CURLOPT_HTTPHEADER => [ | |
"Content-Type: application/x-www-form-urlencoded", | |
"Referer: https://registre.tn/", | |
"User-Agent: insomnia/2023.5.8" | |
], | |
]); | |
$response = curl_exec($curl); | |
$err = curl_error($curl); | |
curl_close($curl); | |
if ($err) { | |
echo "cURL Error #:" . $err; | |
} else { | |
echo $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment