J000291 #513 added, fixes to py file (added how to)

This commit is contained in:
makecakenotwar97@gmail.com
2013-08-19 17:24:51 -04:00
parent c56a73ac04
commit f68458f663
2 changed files with 205 additions and 2 deletions

183
members/J000291.yaml Normal file
View File

@@ -0,0 +1,183 @@
bioguide: J000291
contact_form:
method: POST
action: http://www.johanns.senate.gov/public/?p=EmailSenatorJohanns
steps:
- visit: http://www.johanns.senate.gov/public/?p=EmailSenatorJohanns
- fill in:
# there is a form field for "Military Rank", ignoring
- name: field_c1b69eab-629c-4b35-925e-e9449a63ae88
selector: "#field_c1b69eab-629c-4b35-925e-e9449a63ae88"
value: $NAME_FIRST
required: Yes
- name: field_0d3e4c4d-69f3-43fb-ac36-de73416d9a28
selector: "#field_0d3e4c4d-69f3-43fb-ac36-de73416d9a28"
value: $NAME_LAST
required: Yes
- name: field_0facf361-2a22-4aa8-96a5-2cd3639eb8ab
selector: "#field_0facf361-2a22-4aa8-96a5-2cd3639eb8ab"
value: $ADDRESS_STREET
required: Yes
- name: field_f882d195-4b37-427e-9d55-04e8fd742dbc
selector: "#field_f882d195-4b37-427e-9d55-04e8fd742dbc"
value: $ADDRESS_STREET_2
- name: field_3d660b43-6c6c-4bf6-aa50-f81636b35cf1
selector: "#field_3d660b43-6c6c-4bf6-aa50-f81636b35cf1"
value: $ADDRESS_CITY
required: Yes
- name: field_24b864e4-2705-4c51-88cf-6545c58a7e8e
selector: "#field_24b864e4-2705-4c51-88cf-6545c58a7e8e"
value: $ADDRESS_ZIP5
- name: field_21c46727-b4a7-4cdc-a41c-7c047df04907
selector: "#field_21c46727-b4a7-4cdc-a41c-7c047df04907"
value: $PHONE
- name: field_5689cceb-e8a1-4424-8681-d6ff6804d49f
selector: "#field_5689cceb-e8a1-4424-8681-d6ff6804d49f"
value: $EMAIL
required: Yes
# there is a form field for "Other" topic, ignoring
- name: field_e0eb4dcd-9a9d-4bce-a5d8-f0c9f8a4848b
selector: "#field_e0eb4dcd-9a9d-4bce-a5d8-f0c9f8a4848b"
value: $MESSAGE
required: Yes
- select:
- name: field_e33728dc-9ddc-4901-99db-4df3ec6892ff
selector: "#field_e33728dc-9ddc-4901-99db-4df3ec6892ff"
value: $NAME_PREFIX
options:
- "Mr."
- "Mrs."
- "Ms."
- "Mr. and Mrs."
- "Dr."
- "Dr. and Mrs."
- "Dr. and Mr."
- "Reverend"
- "Pastor"
- "Sister"
- "Military Rank"
- select:
- name: field_74e9c6bc-dd90-46d8-a86a-869c9c909689
selector: "#field_74e9c6bc-dd90-46d8-a86a-869c9c909689"
value: $ADDRESS_STATE_POSTAL_ABBREV
options:
- "AE"
- "AA"
- "AP"
- "AL"
- "AK"
- "AS"
- "AR"
- "AR"
- "CA"
- "Colorado" # I don't know why either
- "CT"
- "DE"
- "DC"
- "FL"
- "GA"
- "GU"
- "HI"
- "ID"
- "IL"
- "IN"
- "IA"
- "KA"
- "KY"
- "LA"
- "ME"
- "MD"
- "MA"
- "MI"
- "MT"
- "MS"
- "MI"
- "MT"
- "NE"
- "NV"
- "NH"
- "NJ"
- "NM"
- "NY"
- "NC"
- "ND"
- "MP"
- "OH"
- "OK"
- "OR"
- "PA"
- "PR"
- "RI"
- "SC"
- "SD"
- "TN"
- "TX"
- "UT"
- "VT"
- "VA"
- "VI"
- "WA"
- "WV"
- "WI"
- "WY"
- select:
- name: field_50fc9c16-75bc-45c4-b850-f00dcfbcf29e
selector: "#field_50fc9c16-75bc-45c4-b850-f00dcfbcf29e"
value: $TOPIC
required: Yes
options:
- "Abortion"
- "Agriculture"
- "Animal Rights"
- "Appropriations"
- "Autographed Photo"
- "Banking"
- "Budget"
- "Crime"
- "Civil Rights"
- "CONSTITUENT SERVICES"
- "Defense/Military"
- "Eagle Scouts"
- "Economy"
- "Education"
- "Energy"
- "Environment"
- "FEMA"
- "Finance"
- "Foreign Affairs"
- "Government Affairs"
- "Guns"
- "Health Care"
- "Health Insurance"
- "Homeland Security"
- "Housing and Urban Development"
- "Immigration"
- "Insurance"
- "Intelligence"
- "Judiciary"
- "Labor"
- "NASA"
- "Nominations"
- "Science/Technology"
- "Small Business"
- "Social Security"
- "Tax"
- "Telecommunications"
- "Tort Reform"
- "Trade"
- "Transportation"
- "U.S. Military Academies"
- "Veterans Affairs"
- "War in Iraq"
- "War on Terror"
- "Welfare"
- "Women's Issues"
- "Other"
- click_on:
- value: "Submit"
selector: "div.buttonHolder input[value=Submit]"
success:
headers:
status: 200
body:
contains: "Thank you for contacting my office to express your views and concerns"

View File

@@ -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 os
import re import re
@@ -6,7 +26,7 @@ YAMLselections = []
#compile regular expressions #compile regular expressions
select = re.compile(r'<select.*?</select>', re.DOTALL) 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 root,dirs,files in os.walk('.\input'):
for file in files: for file in files:
@@ -17,7 +37,7 @@ for root,dirs,files in os.walk('.\input'):
options = re.findall(selectoptions, selector) options = re.findall(selectoptions, selector)
data = '------------\n' + file + '\n' + 'options:' + '\n' data = '------------\n' + file + '\n' + 'options:' + '\n'
for option in options: for option in options:
data = data + " " data = data + " "
data = data + "- " + option + '\n' data = data + "- " + option + '\n'
YAMLselections.append(data) YAMLselections.append(data)
for x in YAMLselections: for x in YAMLselections: