mirror of
https://github.com/Evil0ctal/Douyin_TikTok_Download_API.git
synced 2025-04-21 11:30:16 +08:00
🔧Modified for PyPi
This commit is contained in:
parent
c87f6978c5
commit
9ef19a1150
32
scraper.py
32
scraper.py
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import platform
|
import platform
|
||||||
import asyncio
|
import asyncio
|
||||||
@ -65,20 +66,25 @@ class Scraper:
|
|||||||
self.tiktok_api_headers = {
|
self.tiktok_api_headers = {
|
||||||
'User-Agent': 'com.ss.android.ugc.trill/2613 (Linux; U; Android 10; en_US; Pixel 4; Build/QQ3A.200805.001; Cronet/58.0.2991.0)'
|
'User-Agent': 'com.ss.android.ugc.trill/2613 (Linux; U; Android 10; en_US; Pixel 4; Build/QQ3A.200805.001; Cronet/58.0.2991.0)'
|
||||||
}
|
}
|
||||||
self.config = configparser.ConfigParser()
|
# 判断配置文件是否存在/Check if the configuration file exists
|
||||||
self.config.read('config.ini', encoding='utf-8')
|
if os.path.exists('config.ini'):
|
||||||
# 判断是否使用代理
|
self.config = configparser.ConfigParser()
|
||||||
if self.config['Scraper']['Proxy_switch'] == 'True':
|
self.config.read('config.ini', encoding='utf-8')
|
||||||
# 判断是否区别协议选择代理
|
# 判断是否使用代理
|
||||||
if self.config['Scraper']['Use_different_protocols'] == 'False':
|
if self.config['Scraper']['Proxy_switch'] == 'True':
|
||||||
self.proxies = {
|
# 判断是否区别协议选择代理
|
||||||
'all': self.config['Scraper']['All']
|
if self.config['Scraper']['Use_different_protocols'] == 'False':
|
||||||
}
|
self.proxies = {
|
||||||
|
'all': self.config['Scraper']['All']
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
self.proxies = {
|
||||||
|
'http': self.config['Scraper']['Http_proxy'],
|
||||||
|
'https': self.config['Scraper']['Https_proxy'],
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
self.proxies = {
|
self.proxies = None
|
||||||
'http': self.config['Scraper']['Http_proxy'],
|
# 配置文件不存在则不使用代理/If the configuration file does not exist, do not use the proxy
|
||||||
'https': self.config['Scraper']['Https_proxy'],
|
|
||||||
}
|
|
||||||
else:
|
else:
|
||||||
self.proxies = None
|
self.proxies = None
|
||||||
# 针对Windows系统的异步事件规则/Asynchronous event rules for Windows systems
|
# 针对Windows系统的异步事件规则/Asynchronous event rules for Windows systems
|
||||||
|
Loading…
x
Reference in New Issue
Block a user