""" This script only works with guitar tabs provided by Songsterr.com. Check you have all the modules installed. """ import bs4, requests, sys, math, os import seaborn as sns import matplotlib.pyplot as plt import pandas as pd link = 'https://www.songsterr.com/a/wsa/mastodon-crack-the-skye-tab-s24134t0' name = 'Some name for the title of the heatmap' # get the tab from songster try: res = requests.get(link) except: print('request failed') sys.exit() soup = bs4.BeautifulSoup(res.content, 'html5lib') text = soup.prettify() # the following represents the strings # index 0 is string 1 = e, index 5 = E strings = [{}, {}, {}, {}, {}, {}] failed = [] # add all the frets. -1 = muted note for i in range(0, 6): for j in range(-1, 25): strings[i][j] = 0 def string_and_fret_finder(text, marker): # find tab sentence p0 = text.find('', p2)+len('>') p4 = text.find('<',p3) rawfret = text[p3:p4] # get rid of all the empty space and lines from rawfret fret = [] for i in rawfret: if i == 'X': fret.append(i) else: try: int(i) fret.append(i) except: continue fret = ''.join(fret) if fret == 'X': fret = -1 else: fret = int(fret) return (string, fret, p4) table = pd.DataFrame(columns = ("String", "Fret", "Count")) marker = 0 while text.find('