Created
October 17, 2019 03:03
-
-
Save theagoliveira/e7e09621a65974cced5d11a9792e05e1 to your computer and use it in GitHub Desktop.
Get the price of a product from Cissa Magazine website
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 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