Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gets the EBNF of the Golang spec at https://golang.org/ref/spec
from bs4 import BeautifulSoup
import requests
r = requests.get('http://golang.org/ref/spec')
soup = BeautifulSoup(r.text)
bnf = soup.find_all('pre', class_='ebnf')
bnftxt = [x.get_text() for x in bnf]
bnftxt = ''.join(bnftxt)
with open('go-out.txt', 'w') as f:
f.write(bnftxt.encode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment