Check for user-agents.txt before using it
This commit is contained in:
@@ -255,6 +255,11 @@ end
|
|||||||
# @return [ String ] A random user-agent from data/user-agents.txt
|
# @return [ String ] A random user-agent from data/user-agents.txt
|
||||||
def get_random_user_agent
|
def get_random_user_agent
|
||||||
user_agents = []
|
user_agents = []
|
||||||
|
|
||||||
|
unless File.exist?(USER_AGENTS_FILE)
|
||||||
|
raise('[ERROR] Missing user-agent data. Please re-run with --update.')
|
||||||
|
end
|
||||||
|
|
||||||
f = File.open(USER_AGENTS_FILE, 'r')
|
f = File.open(USER_AGENTS_FILE, 'r')
|
||||||
f.each_line do |line|
|
f.each_line do |line|
|
||||||
# ignore comments
|
# ignore comments
|
||||||
|
|||||||
Reference in New Issue
Block a user