you have to turn off security feature. there is no way to automate this.
https://developer.salesforce.com/forums/?id=906F00000009B1wIAE
It only asks for verification code when I run automation script. It does not ask for verification code when i log in manually. I added the suggested IP ranges from the url you sent in setting but it still asks for verification code. What did you do to make it work for you?