How to set custom user-agent for Mechanize in Rails

You can set the user agent from an alias

a = Mechanize.new
a.user_agent_alias="Mac Safari"

Available aliases are stored in the AGENT_ALIASES constant.

p Mechanize::AGENT_ALIASES

Otherwise, use #user_agent to set your custom user agent.

a = Mechanize.new
a.user_agent="Custom agent"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)