Skip to content

Instantly share code, notes, and snippets.

@chewxy
Created September 3, 2014 03:43
Show Gist options
  • Save chewxy/d9642a9552973dfc0731 to your computer and use it in GitHub Desktop.
Save chewxy/d9642a9552973dfc0731 to your computer and use it in GitHub Desktop.
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