Skip to content

use fake-useragent for UserAgent#12699

Closed
w-e-w wants to merge 1 commit intodevfrom
UserAgent
Closed

use fake-useragent for UserAgent#12699
w-e-w wants to merge 1 commit intodevfrom
UserAgent

Conversation

@w-e-w
Copy link
Collaborator

@w-e-w w-e-w commented Aug 20, 2023

Description

@SpenserCai
as opposed to hard coding a relatively outdated user agent

response = requests.get(encoding, timeout=30, headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'})

chrome 62.0.3202 is from 2017-10-17, it screams bot

we can use a library like fake-useragent https://pypi.org/project/fake-useragent

kind of related PR #12698

a test script

from fake_useragent import FakeUserAgent
ua = user_agent = FakeUserAgent(min_percentage=1.0).random
print(ua)

another method would be to just expose the user method make it editable

Checklist:

@w-e-w w-e-w requested a review from AUTOMATIC1111 as a code owner August 20, 2023 16:23
@AUTOMATIC1111
Copy link
Owner

I added an option to let user specify the user agent if he needs one, and removed the fake one as default.

@w-e-w w-e-w deleted the UserAgent branch August 22, 2023 03:51
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.

2 participants