Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created Nov 22, 2020
Embed
What would you like to do?
import requests
from bs4 import BeautifulSoup
import re
url = "http://shakespeare.mit.edu/henryv/full.html"
def isNamedLine(tag):
return tag.has_attr('name')
websiteText = requests.get(url).text
soup = BeautifulSoup(websiteText, 'lxml')
lines = soup.find_all(isNamedLine)
print(lines)
with open('henryV.txt', "w") as outfile:
for l in lines:
outfile.write(str(l.text) + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment