Skip to content

Commit 3019be5

Browse files
committed
Use random user agent
1 parent 933a0fa commit 3019be5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
requests==2.22.0
22
ordereddict==1.1
3+
fake-useragent==0.1.11

woocommerce/api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
from requests import request
1313
from json import dumps as jsonencode
1414
from time import time
15+
from fake_useragent import FakeUserAgent
1516
from woocommerce.oauth import OAuth
1617

1718
try:
1819
from urllib.parse import urlencode
1920
except ImportError:
2021
from urllib import urlencode
2122

23+
ua = FakeUserAgent()
2224

2325
class API(object):
2426
""" API Class """
@@ -71,7 +73,7 @@ def __request(self, method, endpoint, data, params=None, **kwargs):
7173
url = self.__get_url(endpoint)
7274
auth = None
7375
headers = {
74-
"user-agent": "WooCommerce API Client-Python/%s" % __version__,
76+
"user-agent": ua.random,
7577
"accept": "application/json"
7678
}
7779

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy