Skip to content

Instantly share code, notes, and snippets.

Created Sep 3, 2014
What would you like to do?
Gets the EBNF from the ECMAScript 5.1 spec
from bs4 import BeautifulSoup
import requests
r = requests.get('')
soup = BeautifulSoup(r.text)
sections = ('sec-A.1', 'sec-A.2', 'sec-A.3', 'sec-A.4', 'sec-A.5')
appendix = []
for s in sections:
bnf = []
for a in appendix:
divs = a.find_all('div', class_='gp')
bnf += [x.get_text() for x in divs]
bnftxt = '\n'.join([x.strip('\n').replace('\n', ' ') for x in bnf])
with open('jsout.txt', 'w') as f:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment