174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/ecfs.rb', line 174
def self.search(docket: nil, size: 1000, start: 0, order: 'asc')
url = "http://apps.fcc.gov/ecfs/comment_search_solr/doSearch?proceeding=#{docket}&dir=#{order}&start=#{start}&size=#{size}"
doc = Nokogiri::HTML(open(url))
xpath = "//*[@id='yui-main']/div/div[4]"
table = doc.xpath(xpath).children[1]
rows = table.search('tr')
rows.shift
filings = []
rows.each do |row|
row_hash = {}
cols = row.search('td')
cols.each_with_index do |col, i|
attribute = ECFS::Filings::ATTRS[i]
row_hash[attribute] = col.text.strip
if attribute == :filer
path = col.search('a').first.attributes["href"].value
id = path.split('?id=')[1]
url = "http://apps.fcc.gov/ecfs/comment/view?id=#{id}"
row_hash[:url] = url
end
end
row_hash[:received] = DateTime.parse(row_hash[:received]).to_s
row_hash[:posted] = DateTime.parse(row_hash[:posted]).to_s
row_hash[:pages] = row_hash[:pages].to_i
filings << row_hash
end
filings
end
|