mirror of
https://github.com/unitedstates/contact-congress.git
synced 2025-12-19 17:37:24 -05:00
J000291 #513 added, fixes to py file (added how to)
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
'''
|
||||
HOW TO USE:
|
||||
Copy this file to a separate location (so as not to hide random files
|
||||
to github)
|
||||
|
||||
Create a folder named "input" in the same location
|
||||
|
||||
Copy the section of the HTML containing the form options that you
|
||||
want to extract (does not have to be exact, you can even copy and paste
|
||||
the entire HTML source code if you want, only there is less chance for
|
||||
errors if you only copy/paste the section containing the form)
|
||||
|
||||
Paste into a text file (NOT word) and save in the "input" folder.
|
||||
|
||||
Run the .py file in python 3.3, and copy/paste the resulting output.
|
||||
|
||||
It is recommended to check the output for any errors (if the attribute is
|
||||
in single quotes you can change this in the regular expression below to
|
||||
r'(?:<option.*?value\s*=\s*)(\'.*?\')'.
|
||||
'''
|
||||
|
||||
import os
|
||||
import re
|
||||
@@ -6,7 +26,7 @@ YAMLselections = []
|
||||
|
||||
#compile regular expressions
|
||||
select = re.compile(r'<select.*?</select>', re.DOTALL)
|
||||
selectoptions = re.compile(r'(?:<option.*?value\s*=\s*)([\'\"].*?[\'\"])')
|
||||
selectoptions = re.compile(r'(?:<option.*?value\s*=\s*)(\".*?\")')
|
||||
|
||||
for root,dirs,files in os.walk('.\input'):
|
||||
for file in files:
|
||||
@@ -17,7 +37,7 @@ for root,dirs,files in os.walk('.\input'):
|
||||
options = re.findall(selectoptions, selector)
|
||||
data = '------------\n' + file + '\n' + 'options:' + '\n'
|
||||
for option in options:
|
||||
data = data + " "
|
||||
data = data + " "
|
||||
data = data + "- " + option + '\n'
|
||||
YAMLselections.append(data)
|
||||
for x in YAMLselections:
|
||||
|
||||
Reference in New Issue
Block a user