从internet获取可用代理的Python包
hideme的Python项目详细描述
隐藏名
HideMe是一个python包,用于从免费代理网站收集可用的代理 可通过pip安装,如下所示。在
pip install hideme
文件
HideMe返回的代理的格式如下
^{pr2}$你可以得到如下所示的代理
fromhideme.proxy_collectorimportProxiesListproxy_list=ProxiesList()proxy=proxy_list.get()
输出:
[{"ip_address":"88.198.50.103","port":"8080","country_code":"DE","country":"Germany","anonymity":"anonymous","google_support":False,"https":False}]
通过向get方法传递count param,可以获得所需数量的代理。在
fromhideme.proxy_collectorimportProxiesListproxies_list=ProxiesList()proxies=proxies_list.get(count=2)
输出:
[{"ip_address":"88.198.50.103","port":"8080","country_code":"DE","country":"Germany","anonymity":"anonymous","google_support":False,"https":False},{"ip_address":"187.45.123.137","port":"36559","country_code":"BR","country":"Brazil","anonymity":"elite proxy","google_support":False,"https":True}]
您还可以通过将filter参数传递给ProxiesList类来过滤返回的代理。例子用法:在
这将只返回位于Country-Spain
fromhideme.proxy_collectorimportProxiesListproxies_list=ProxiesList(country='Spain')proxies=proxies_list.get()
输出:
[{"ip_address":"185.44.232.30","port":"53281","country_code":"ES","country":"Spain","anonymity":"elite proxy","google_support":False,"https":False},{"ip_address":"82.223.3.52","port":"8118","country_code":"ES","country":"Spain","anonymity":"elite proxy","google_support":False,"https":False}]
这将只返回那些支持HTTPS的代理
fromhideme.proxy_collectorimportProxiesListproxies_list=ProxiesList(https=True)proxies=proxies_list.get()
输出
[{"ip_address":"201.217.4.101","port":"53281","country_code":"PY","country":"Paraguay","anonymity":"elite proxy","google_support":False,"https":True},{"ip_address":"13.233.160.59","port":"80","country_code":"IN","country":"India","anonymity":"elite proxy","google_support":False,"https":True}]
您也可以像下面这样组合多个过滤器参数
fromhideme.proxy_collectorimportProxiesListproxies_list=ProxiesList(country='India',https=True,port='80',google_support=False)proxies=proxies_list.get()
输出
[{"ip_address":"13.233.160.59","port":"80","country_code":"IN","country":"India","anonymity":"elite proxy","google_support":False,"https":True}]
- 项目
标签: