Last active
January 8, 2019 17:15
-
-
Save kissgyorgy/8627598a1edf1f9d92c186b2c478c965 to your computer and use it in GitHub Desktop.
Python: Randomly choose a pizza from a Pizza place's webpage
This file contains hidden or 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
#!/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