Skip to content

Instantly share code, notes, and snippets.

@kostasdizas
Created April 28, 2016 11:44
Show Gist options
  • Save kostasdizas/0847a211b096a0dd13b13004905d212a to your computer and use it in GitHub Desktop.
Save kostasdizas/0847a211b096a0dd13b13004905d212a to your computer and use it in GitHub Desktop.
Adastral Hub Menu
#!/usr/bin/env python
"""
Find the Adastral Park Hub Menu
"""
from __future__ import print_function
import re
import webbrowser
from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup as bs
def ask_open_in_browser(link):
"""Ask whether the given link should be opened in a browser"""
keep_asking = True
while keep_asking:
answer = raw_input("[?] Open in browser? [yn] ")
if answer != '':
answer = answer[0].lower()
if answer in ['y', 'n']:
keep_asking = False
if answer == 'y':
webbrowser.open(link)
elif answer == 'n':
pass
else:
print("[!] Invalid option, try again!")
def main():
"""Download their main website, find and display the PDF link"""
soup = bs(urlopen('https://atadastral.co.uk/'))
for pdf in soup.findAll(href=re.compile(r'menu.*\.pdf$')):
link = pdf['href']
print("[+] Here is your menu good sir.")
print("[+] {0}".format(link))
ask_open_in_browser(link)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment