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

Update online_getter.py for request issue #2

Merged
merged 1 commit into from
Nov 9, 2019

Conversation

maliozer
Copy link
Contributor

@maliozer maliozer commented Nov 5, 2019

simply header added and get image from /image url while for better request

simply header added and get image from /image url while for better request
@@ -10,8 +10,8 @@ def get_online_person(params=None, **kwargs) -> bytes:
:param kwargs: kwargs used by requests.get
:return: the image as bytes
"""
r = requests.get("https://thispersondoesnotexist.com/", params, **kwargs)
return r.content
r = requests.get("https://thispersondoesnotexist.com/image", headers={'User-Agent': 'My User Agent 1.0'}).content
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, however I'd remove the headers part, if anybody wants to customize the User-Agent or anything, they can just pass it as a kwargs. Or we could use requests_html to have a randomized user agent.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH, I see! the problem is thispersondoesnotexist.com raise an error when no User-Agent is passed!

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

Successfully merging this pull request may close these issues.

None yet

2 participants