initial commit

This commit is contained in:
Mitch Weaver
2018-04-23 17:56:32 +02:00
commit 39eb9205cf
18 changed files with 523 additions and 0 deletions

33
logo Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python3
#
# http://github.com/mitchweaver/bin
#
# get a given band logo from metal-archives.com
#
from bs4 import BeautifulSoup
import urllib
import sys
def band_logo(band):
try:
url = 'https://www.metal-archives.com/bands/' + band.replace(' ', '_').lower()
def get_soup(url,header):
return BeautifulSoup(urllib.request.urlopen(urllib.request.Request(url,headers=header)), "html5lib")
header = {'User-Agent': 'Mozilla/5.0'}
image_urls = [a['src'] for a in get_soup(url, header).find_all("img")]
image = urllib.request.urlopen(image_urls[1]).read()
file = open("./logo.jpg", 'wb')
file.write(image)
file.close()
except:
print("Error - can't find it?")
def main():
band_logo(sys.argv[1])
if __name__ == "__main__": main()