#soup = BeautifulSoup(html_doc, ‘html.parser’)
#print(soup.prettify())
#for link in soup.find_all(‘a’):
# print(link.get(‘href’))

#file = open(“links.txt”, “w”)
#for link in soup.find_all(‘a’):
# file.write(str(link.get(‘href’))+”\n”)

return render_template(“homepage.html”)


@app.route(“/about”)
def about():
return render_template(“about.html”)


@app.route(“/search”, methods=[“GET”, “POST”])
def search():
if request.method == “POST”:
url = request.form[“url”]
r = requests.get(url)
soup = BeautifulSoup(r.text, “html5lib”)

# kill all script and style elements
for script in soup([“script”, “style”]):
script.extract() # rip it out

# get text
text = soup.get_text()

# break into lines and remove leading and trailing space on each
lines = (line.strip() for line in text.splitlines())

# break multi-headlines into a line each
chunks = (phrase.strip() for line in lines for phrase in line.split(” “))

# drop blank lines
text = ‘\n’.join(chunk for chunk in chunks if chunk)

print(text)

return render_template(“search2.html”)