From 76c54149d21b4b88f2ad2919cd06b56df4c14b23 Mon Sep 17 00:00:00 2001 From: Bigsk <1332540+bigskcode@user.noreply.gitee.com> Date: Sun, 26 Jul 2020 19:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9D=97httpget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- synchronize/synchronize.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/synchronize/synchronize.py b/synchronize/synchronize.py index 9e2258d..7f6940d 100644 --- a/synchronize/synchronize.py +++ b/synchronize/synchronize.py @@ -71,6 +71,12 @@ def sychronize(url, filepath): log('[ERROR]:There has a error in task of synchronizing the file ' + SavePath + filepath + '.') else: log('[INFO]:The file ' + SavePath + filepath + ' has been synchronized successfully.') +#Function Which Be Used To Get HTTP Site With Requests Avoid Error. +def httpget(url): + try: + return requests.get(url=url, headers=UserAgent).text + except: + return 'error' log('[INFO]:Loading all kinds of functions successfully.') #------------------------------------------------------------------------#