遍历多个 txt 文件进行获取值
import random
def load_config(path):
with open(path,'r') as tou:
return [line for line in tou.readlines()]
headers = {
'User-Agent':load_config('useragents.txt')[random.randint(0,len(load_config('useragents.txt'))-1)].strip("\n"),
'Referer':load_config('referers.txt')[random.randint(0,len(load_config('referers.txt'))-1)].strip("\n"),
'Accept':load_config('acceptall.txt')[random.randint(0,len(load_config('acceptall.txt'))-1)].strip("\n"),
}
print(headers)
2020-04-25 00:52:04
本文来自博客园,作者:Hany47315,转载请注明原文链接:https://www.cnblogs.com/hany-postq473111315/p/12771248.html

浙公网安备 33010602011771号