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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update online_getter.py for request issue
simply header added and get image from /image url while for better request
  • Loading branch information
maliozer committed Nov 5, 2019
commit 4488c9b6bb6d6f22cba3f3eb3d5c799934982698
4 changes: 2 additions & 2 deletions thispersondoesnotexist/online_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!

return r


def save_online_person(file: str = None, params=None, **kwargs) -> int:
Expand Down