Skip to content

Instantly share code, notes, and snippets.

@theagoliveira
Created October 17, 2019 03:03
Show Gist options
  • Save theagoliveira/e7e09621a65974cced5d11a9792e05e1 to your computer and use it in GitHub Desktop.
Save theagoliveira/e7e09621a65974cced5d11a9792e05e1 to your computer and use it in GitHub Desktop.
Get the price of a product from Cissa Magazine website
#!/usr/bin/env python
"""
Get the price of a product from Cissa Magazine website.
"""
import argparse
import re
import urllib.request as req
__author__ = 'Thiago Cavalcante'
DESC = 'Get the price of a product from Cissa Magazine website.'
TAG = '<meta itemprop="price" content="(.*?)">'
parser = argparse.ArgumentParser(description=DESC)
parser.add_argument('-u', '--url', help='Product URL', required=True)
args = parser.parse_args()
src = str(req.urlopen(args.url).read())
price = re.findall(TAG, src)[0].replace('.', ',')
print('Price: R$ ' + price)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment