Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Last active January 8, 2019 17:15
Show Gist options
  • Save kissgyorgy/8627598a1edf1f9d92c186b2c478c965 to your computer and use it in GitHub Desktop.
Save kissgyorgy/8627598a1edf1f9d92c186b2c478c965 to your computer and use it in GitHub Desktop.
Python: Randomly choose a pizza from a Pizza place's webpage
#!/usr/bin/env python3
import random
from lxml import etree
import requests
import urllib3
def main(url):
# It serves over SSLv3 which requests doesn't accept on bionic
response = requests.get(url, verify=False)
root = etree.HTML(response.content)
pizzas = root.xpath('//h3')
random_pizza = random.choice(pizzas).text
print(random_pizza)
if __name__ == '__main__':
urllib3.disable_warnings()
main('https://pizzaforte.hu/pizzak.php')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment