Updated user agent retrieval and added lines for PEP8.