Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser list has no values, raising FakeUserAgentError in fake.py", line 140, #59

Closed
MuhammadRahman-awin opened this issue Nov 3, 2017 · 2 comments

Comments

@MuhammadRahman-awin
Copy link

MuhammadRahman-awin commented Nov 3, 2017

Hi there,

For whatever reason, the self.data['browsers']/self.data_browsers[browser] has only keys, no values,

{u'chrome': [], u'opera': [], u'firefox': [], u'internetexplorer': [], u'safari': []}

Therefore our production cron is broken due to this error

raise FakeUserAgentError('Error occurred during getting browser')  # noqa

So I am asking you to return a default browser if choice is empty.
i.e in line https://github.com/hellysmile/fake-useragent/blob/master/fake_useragent/fake.py#L136

if not self.data_browsers[browser]:
    return random.choice(['firefox', 'chrome', 'opera', 'safari']) # i.e a fallback list
return random.choice(self.data_browsers[browser])

Hope you can give a better solution.

@hellysmile
Copy link
Collaborator

It was fixed yesterday, at version 0.1.8! Can You try to update?

@MuhammadRahman-awin
Copy link
Author

MuhammadRahman-awin commented Nov 7, 2017

Oh, didn't notice this and created a PR, going to try now :)
And it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants