else without rescue is useless and expecting keyword_end

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

else without rescue is useless and expecting keyword_end



This code gives me these errors in my ruby console:



1) warning: else without rescue is useless



2) syntax error, unexpected end-of-input, expecting keyword_end



Why am I getting both of these errors at the same time?


require 'nokogiri'
require 'httparty'
require 'byebug'
require 'awesome_print'
require 'watir'

def input #takes user input and grabs the url for that particular search

puts "1) Enter the job title that you want to search for n"
j_input = gets.chomp
job = j_input.split(/ /).join("+")
puts "================================= n"

puts "1/2)Do you want to input city-and-state(1) or zipcode(2)? n"
choice = gets.chomp

if choice == "1"

puts "2) Enter the city that you want to search for n"
city_input = gets.chomp
city = city_input.split(/ /).join("+")
puts "================================= n"

puts "3) Enter the state that you want to search for n"
state_input = gets.chomp
state = "+" + state_input

puts target_url = "https://www.indeed.com/resumes/?q=#job&l=#city%2C#state&cb=jt"


elsif choice == "2"

puts "Enter the zipcode that you want to search for n"
zipcode = gets.chomp

puts target_url = "https://www.indeed.com/resumes?q=#job&l=#zipcode&cb=jt"

else
puts "error"
end


unparsed_page = HTTParty.get(target_url)
parsed_page = Nokogiri::HTML(unparsed_page)
resume_listing = parsed_page.css('div.sre-entry')
per_page = resume_listing.count
resumes = Array.new
counter = 0
result_count = parsed_page.css('div#result_count').text.split(' ')[0].to_f
page_count = (result_count.to_f / per_page.to_f ).ceil
current_count = 0
byebug

if counter <= 0
unparsed_page = HTTParty.get(target_url)
parsed_page = Nokogiri::HTML(unparsed_page)
resume_listing = parsed_page.css('div.sre-entry')
per_page = resume_listing.count
pagination_resume_listing.each do |resume_listing|

#resume_info =

# title:
# link:
# skills:
# education:
#
#resumes << resume_info

puts "Added #resume_info[:title]"

else

while current_count <= page_count * per_page
pagination_url = "https://www.indeed.com/resumes?q=#job&l=#zipcode&co=US&cb=jt&start=#current_count"
unparsed_pagination_page = HTTParty.get(pagination_url)
pagination_parsed_page = Nokogiri::HTML(unparsed_pagination_page)
pagination_resume_listing = pagination_parsed_page.css('div.sre-entry')
pagination_resume_listing.each do |resume_listing|

#resume_info =

# title:
# link:
# skills:
# education:
#
#resumes << resume_info

puts "Added #resume_info[:title]"
current_count += 50
end

end
end
end
end



It won't allow me to fix the else without rescue issue without telling me that it expects an extra end at the end of my code. Of course when I put the end there it does nothing and says that it wants another end





If you format (i.e. indent) your code, it should help ID your missing end statement.
– orde
8 mins ago


end









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

PySpark count values by condition

Mass disable jenkins jobs