Skip to content

Instantly share code, notes, and snippets.

@putarpuar
Created September 10, 2018 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save putarpuar/5471a01f581cc983c8284fd1d6369dd2 to your computer and use it in GitHub Desktop.
Save putarpuar/5471a01f581cc983c8284fd1d6369dd2 to your computer and use it in GitHub Desktop.
package ubuntu version
import urllib.request
import re
import io
packages = ["apache2", "java-common", "nginx", "vim", "slurm"]
regex="<h1>(.*)</h1>"
for i in packages:
url = "https://packages.ubuntu.com/bionic/%s" % i
req = urllib.request.Request(url)
resp = urllib.request.urlopen(req)
respData = resp.read()
h1 = re.findall(regex, str(respData))
split = h1[0].split()
slice_str = str(split[2])
test = re.match(r"^\d{1}(.*)\d{1}", slice_str[1:])
print(test.group(0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment