import os, requests, urllib from markdown import markdown from bs4 import BeautifulSoup url = "https://pad.xpub.nl/p/jargon-file/export/txt" data = urllib.request.urlopen(url).read() #bytes object string = data.decode() # print(string) html = markdown(string) # print(html) soup = BeautifulSoup(html) headers = soup.find_all('h1') # print(headers) cmd = '#network' query = cmd.replace('#','') for header in soup('h1'): if query in header.string: print(header.string) print('---')