Created
September 3, 2014 03:43
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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