Advertisement
ssoni

embassy.py

Apr 11th, 2025
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import requests
  2. import re
  3.  
  4. # Download the HTML page
  5. def getPage(url):
  6.     response = requests.get(url)
  7.     return response.text
  8.  
  9. def main():
  10.     url = "https://travel.state.gov/content/travel/en/us-visas/visa-information-resources/list-of-posts.html"
  11.     topPage = getPage(url)
  12.     links = re.findall("href=\"(.+\.html)", topPage)
  13.     for link in links:
  14.         fullURL = 'https://travel.state.gov' + link
  15.         page = getPage(fullURL)
  16.         emails = re.findall("mailto: (\S+@\S+\.(gov|edu|com))", page)
  17.         for email in emails:
  18.             print(email[0])
  19.  
  20. main()
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement