from bs4 import BeautifulSoup from urllib.parse import quote as urlquote, unquote as urlunquote file = open('tag_comparison.py', 'r') x = 1 print(read) with open(file, 'w') as new_html: read = new_html.read() html = BeautifulSoup(text, 'html.parser') line = html.find('NN', 'span')