Skip to content

Commit

Permalink
Update parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
imustafin committed Dec 4, 2024
1 parent 95e975c commit 464bc84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/lib/vk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ def self.retry_handle_429(response, desired_uri)
queries['key'] = digest
x.query = queries.to_query

last_response = Net::HTTP.get_response(x)
challenge_response = Net::HTTP.get_response(x)

raise 'Vk 429 not success' if last_response['x-challenge'] != 'success'
s429 = CGI.parse(URI.join(vk, last_response['location']).query)['s429'].first
raise 'Vk 429 not success' if challenge_response['x-challenge'] != 'success'
cookies = challenge_response['set-cookie']
location = URI.join(vk, challenge_response['location'])

URI("#{desired_uri}&s429=#{s429}")
redirected = Net::HTTP.get_response(location, { 'Cookie' => cookies })

URI.join(vk, redirected['location'])
end

def self.parse_salt(s)
Expand Down Expand Up @@ -129,6 +132,8 @@ def self.js_func(s, arg = nil)
end
end
return nil
else
raise "Unknown function #{s}"
end
end

Expand Down
5 changes: 5 additions & 0 deletions lib/tasks/parse.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace :parse do
ParseBoardWorker.perform_async(135725718, 34975471)
end

desc "Parse packages from https://vk.com/topic-228528109_53000017"
task vk_si_2: :environment do
ParseBoardWorker.perform_async(228528109, 53000017)
end

desc "Parse one post by post id synchronously"
task :vk_si_game_one, [:id] => :environment do |t, args|
ParseBoardWorker.new.parse_one_post(135725718, 34975471, args[:id])
Expand Down

0 comments on commit 464bc84

Please sign in to comment.