From 27f9160d3790c998e0f3081a8fb0b2c71f60f999 Mon Sep 17 00:00:00 2001 From: Lim Kok Hole Date: Wed, 22 Mar 2023 20:17:08 +0800 Subject: [PATCH] Set latest UA --- README.md | 2 +- pinterest-downloader.py | 6 +++++- requirements.txt | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 238394e..e42fa53 100755 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Download all images/videos from Pinterest user/board/section. ### Requirements: - $ python3 -m pip install -r requirements.txt + $ python3 -m pip install --upgrade -r requirements.txt ### Usage: diff --git a/pinterest-downloader.py b/pinterest-downloader.py index 628e4ae..cbe2128 100755 --- a/pinterest-downloader.py +++ b/pinterest-downloader.py @@ -92,8 +92,11 @@ from concurrent.futures import ThreadPoolExecutor, as_completed from http.cookies import SimpleCookie from requests.cookies import cookiejar_from_dict +from fake_useragent import UserAgent +ua = UserAgent() # RIP UA, https://groups.google.com/a/chromium.org/forum/m/#!msg/blink-dev/-2JIRNMWJ7s/yHe4tQNLCgAJ -UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.0.0 Safari/537.36' +#UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.0.0 Safari/537.36' +UA = ua.chrome # MAX_PATH 260 need exclude 1 terminating null character # if prefix \\?\ + abspath to use Windows extented-length(i.e. in my case, individual filename/dir can use full 259, no more 259 is fit full path), then the MAX_PATH is 259 - 4 = 255 @@ -1596,6 +1599,7 @@ def run_library_main(arg_path :str, arg_dir :str, arg_thread_max :int, arg_cut : proxies = dict(http=arg_http_proxy, https=arg_https_proxy) cookies = str(arg_cookies) + print('User Agent: ' + UA) arg_path = arg_path.strip() if arg_path.startswith('https://pin.it/'): diff --git a/requirements.txt b/requirements.txt index f62a15b..f562d22 100755 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ lxml requests termcolor pysocks +fake-useragent