Take that spez. uesr agent randomization
This commit is contained in:
parent
92a2f468c9
commit
6a401a459a
@ -1,4 +1,5 @@
|
||||
import random
|
||||
import string
|
||||
import requests
|
||||
|
||||
def get_image(boards, nsfw=False):
|
||||
@ -30,9 +31,16 @@ def get_image(boards, nsfw=False):
|
||||
# Append this header to the request. Tells the API to only return SFW results
|
||||
request_string += '?obey_over18=true'
|
||||
|
||||
# Spoof our user agent with each request so we dont get rate limited
|
||||
random_user_agent = ''.join(
|
||||
random.SystemRandom().choice(
|
||||
string.ascii_uppercase + string.digits
|
||||
) for _ in range(5)
|
||||
)
|
||||
|
||||
response = requests.get(
|
||||
request_string,
|
||||
headers = {'User-agent':'discord dragon-bot'}
|
||||
headers = {'User-agent':random_user_agent}
|
||||
).json()[0]['data']['children'][0]
|
||||
|
||||
if response['data']['domain'] not in domains:
|
||||
|
Loading…
x
Reference in New Issue
Block a user