自动 构建获取USER_AGENT 和 PROXY_LIST

Posted zach0812

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动 构建获取USER_AGENT 和 PROXY_LIST相关的知识,希望对你有一定的参考价值。

技术图片
 1 import json
 2 ‘‘‘
 3 打开网页,直接保存网页proxy_list.txt ,然后用工具将其处理为 json 文件!   
 4 ‘‘‘
 5 with open("proxy_list.json","r",encoding="utf8") as f:
 6     data_lists = json.load(f)
 7 
 8 final_data = []
 9 for data_dict in data_lists :
10     address_sets = set(data_dict["export_address"])  #变为 set 去重
11     port = data_dict["port"]
12     type =data_dict["type"]
13     # print(address_sets)
14     for address in address_sets:
15         temp = {type :address + ":" + str(port)}
16         # print(temp)
17         final_data.append(temp)
18 with open("PROXY_LISTS.json","a+",encoding="utf8") as f:
19     json.dump(final_data,f)
20     print(len(final_data))
View Code

 

 

import json
‘‘‘
开网页,直接保存网页proxy_list.txt ,然后用工具 json 文件!
‘‘‘
with open("proxy_list.json","r",encoding="utf8") as f:
data_lists = json.load(f)

final_data = []
for data_dict in data_lists :
address_sets = set(data_dict["export_address"]) #变为 set 去重
port = data_dict["port"]
type =data_dict["type"]
# print(address_sets)
for address in address_sets:
temp = {type :address + ":" + str(port)}
# print(temp)
final_data.append(temp)
with open("PROXY_LISTS.json","a+",encoding="utf8") as f:
json.dump(final_data,f)
print(len(final_data))


以上是关于自动 构建获取USER_AGENT 和 PROXY_LIST的主要内容,如果未能解决你的问题,请参考以下文章

爬虫基础知识(web前端,请求模块urllib,重构user_agent)

8.限定某个目录禁止解析php&限制user_agent

限定某个目录禁止解析php 限制user_agent php相关配置

Scrapy Shell - 如何更改 USER_AGENT

利用nginx来屏蔽指定的user_agent的访问以及根据user_agent做跳转

错误无法加载此类文件 -- user_agent/browsers/playstation (LoadError)