Skip to content

Instantly share code, notes, and snippets.

@theagoliveira
Created April 6, 2020 21:54
Show Gist options
  • Save theagoliveira/a984f49b81832f2ed2311c8d5a2de659 to your computer and use it in GitHub Desktop.
Save theagoliveira/a984f49b81832f2ed2311c8d5a2de659 to your computer and use it in GitHub Desktop.
Get the number of available products on MercadoLivre, using the URL
#!/usr/bin/env python
"""
Get the number of available products on MercadoLivre, using the URL
"""
import re
import sys
import urllib.request as req
p_url = sys.argv[1]
with req.urlopen(p_url) as resp:
p_src = resp.read().decode("utf-8")
n_available = re.findall('quantity-available">\((.*)\)</span>', p_src)[0]
print(n_available)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment