Top Level Namespace
Defined Under Namespace
Modules: Registerbekanntmachungen
Instance Method Summary collapse
- #file_name(date) ⇒ Object
- #get_detailed_announcement(datum, id, view_state, cookies) ⇒ Object
-
#oldest_unsaved_date ⇒ Object
Add this method to determine the oldest unsaved date in the last 8 weeks.
-
#parse_announcement(lines, onclick) ⇒ Object
Parse the announcement details from the given text lines and onclick attribute.
- #parse_announcement_response(response_body) ⇒ Object
Instance Method Details
#file_name(date) ⇒ Object
40 41 42 |
# File 'lib/registerbekanntmachungen.rb', line 40 def file_name(date) "db/#{date.strftime('%Y-%m')}/registerbekanntmachungen-#{date.strftime('%Y-%m-%d')}.json" end |
#get_detailed_announcement(datum, id, view_state, cookies) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/registerbekanntmachungen/parser.rb', line 139 def get_detailed_announcement(datum, id, view_state, ) uri = URI('https://www.handelsregister.de/rp_web/xhtml/bekanntmachungen.xhtml') # Prepare the POST data post_data = { 'javax.faces.partial.ajax' => 'true', 'javax.faces.source' => 'bekanntMachungenForm:j_idt114', 'javax.faces.partial.execute' => 'bekanntMachungenForm', 'javax.faces.partial.render' => 'bekanntMachungenForm', 'bekanntMachungenForm:j_idt114' => 'bekanntMachungenForm:j_idt114', 'datum' => datum, 'id' => id, 'bekanntMachungenForm' => 'bekanntMachungenForm', 'javax.faces.ViewState' => view_state # Include other necessary form data if required } headers = { 'Cookie' => , 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8', 'Faces-Request' => 'partial/ajax', 'User-Agent' => 'Your User Agent' } # Create and send the POST request http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, headers) request.set_form_data(post_data) response = http.request(request) # Parse the response response.body end |
#oldest_unsaved_date ⇒ Object
Add this method to determine the oldest unsaved date in the last 8 weeks
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/registerbekanntmachungen.rb', line 26 def oldest_unsaved_date # Calculate the range of the last 8 weeks max_date = Date.today - 7 * 8 date_range = (max_date..(Date.today - 1)).to_a # Find the oldest date without a JSON file date_range.each do |date| filename = "db/#{date.strftime('%Y-%m')}/registerbekanntmachungen-#{date.strftime('%Y-%m-%d')}.json" return date unless File.exist?(filename) end nil # Return nil if all dates are already saved end |