Where are you copying and pasting your code from? What do you expect user_agent random_ua; to do?
In reply to Re: Scrappy user_agent error by marto in thread Scrappy user_agent error by docster