報錯:json
FakeUserAgentError('Maximum amount of retries reached')
禁用服務器緩存:緩存
ua = UserAgent(use_cache_server=False) 無效
不緩存數據: ua = UserAgent(cache=False) 無效
忽略ssl驗證: ua = UserAgent(verify_ssl=False) 無效
解決辦法:服務器
下載: https://fake-useragent.herokuapp.com/browsers/0.1.11 並另存爲:fake_useragent.json
def get_header(): location = os.getcwd() + '/fake_useragent.json' ua = fake_useragent.UserAgent(path=location) return ua.random