Skip to content

Instantly share code, notes, and snippets.

@anmolj7
Created December 3, 2019 19:58
Show Gist options
  • Save anmolj7/f97f0413cfe665a0f56be0e54b22731a to your computer and use it in GitHub Desktop.
Save anmolj7/f97f0413cfe665a0f56be0e54b22731a to your computer and use it in GitHub Desktop.
I first tried with requests and bs4 but it didn't work, the captcha came, so, instead, I had to use mechanize to browse the url, I mean, I could've used mechanize to fill out the form, and then, parse html, but why bother when you can just do this?
import mechanize
from bs4 import BeautifulSoup
name = input("Enter the name you wanna search for: ").replace(" ", "+")
br = mechanize.Browser()
br.addheaders = [("User-agent","Mozilla/5.0")]
resp = br.open("https://viewdns.info/reversewhois/?q={}".format(name))
soup = BeautifulSoup(resp.read(), "lxml")
soup = soup.find("table", attrs={'id':'null'})
soup = soup.find('table')
print("The following mached the records: ")
for x in soup.findAll('tr'):
print(x.find('td').text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment