Advertisement
Diggernaut

Charter Schools in Illinois Digger Config

Feb 14th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.27 KB | None | 0 0
  1. ---
  2. config:
  3.     debug: 2
  4.     agent: "Firefox"
  5. do:
  6. - walk:
  7.     to: 'http://www.illinoisschools.com/charter.aspx'
  8.     do:
  9.     - find:
  10.         path: 'table[width="650"]'
  11.         do:
  12.         - find:
  13.             path: a
  14.             do:
  15.             - parse:
  16.                 attr: href
  17.             - walk:
  18.                 to: value
  19.                 do:
  20.                 - find:
  21.                     path: td[valign="top"]:has(a:contains('Get Directions'))
  22.                     do:
  23.                     - split:
  24.                         context: html
  25.                         delimiter: '<br/>'
  26.                     - object_new: school
  27.                     - find:
  28.                         path: div.element_0
  29.                         do:
  30.                        - parse
  31.                         - normalize:
  32.                             routine: replace_substring
  33.                             args:
  34.                                ^\s+|\s+$: ''
  35.                         - object_field_set:
  36.                             object: school
  37.                             field: name
  38.                     - find:
  39.                         path: div.element_1
  40.                         do:
  41.                        - parse
  42.                         - normalize:
  43.                             routine: replace_substring
  44.                             args:
  45.                                ^\s+|\s+$: ''
  46.                         - object_field_set:
  47.                             object: school
  48.                             field: street
  49.                     - find:
  50.                         path: div.element_2
  51.                         do:
  52.                         - parse:
  53.                             filter: \s*([^,]+),
  54.                         - object_field_set:
  55.                             object: school
  56.                             field: city
  57.                     - register_set: IL
  58.                     - object_field_set:
  59.                         object: school
  60.                         field: state
  61.                     - find:
  62.                         path: div.element_2
  63.                         do:
  64.                         - parse:
  65.                             filter: (\d+)
  66.                         - object_field_set:
  67.                             object: school
  68.                             field: zip
  69.                     - find:
  70.                         path: div.element_4
  71.                         do:
  72.                         - parse:
  73.                             filter: '(.+)\s+County,\s+Illinois'
  74.                         - normalize:
  75.                             routine: replace_substring
  76.                             args:
  77.                                ^\s+|\s+$: ''
  78.                         - object_field_set:
  79.                             object: school
  80.                             field: county
  81.                     - find:
  82.                         path: div.element_5
  83.                         do:
  84.                        - parse
  85.                         - normalize:
  86.                             routine: replace_substring
  87.                             args:
  88.                                ^\s+|\s+$: ''
  89.                         - object_field_set:
  90.                             object: school
  91.                             field: phone
  92.                     - object_save:
  93.                         name: school
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement