用于ip2proxy数据库的python api。它可以用来查询IP地址,如果它被用作开放代理、Web代理、VPN匿名器和Tor退出。

IP2Prox的Python项目详细描述


ip2proxy python库

该库允许用户查询IP地址,如果它被用作开放代理、Web代理、VPN匿名器和Tor退出。它从ip2proxy bin data文件中查找代理IP地址。此数据文件可在

有关更多详细信息,请访问: https://www.ip2location.com/ip2proxy/developers/python

方法

下面是此库中支持的方法。

Method NameDescription
openOpen the IP2Proxy BIN data with File I/O mode for lookup.
closeClose and clean up the file pointer.
get_package_versionGet the package version (1 to 8 for PX1 to PX8 respectively).
get_module_versionGet the module version.
get_database_versionGet the database version.
is_proxyCheck whether if an IP address was a proxy. Returned value:
  • -1 : errors
  • 0 : not a proxy
  • 1 : a proxy
  • 2 : a data center IP address
get_allReturn the proxy information in array.
get_proxy_typeReturn the proxy type. Please visit IP2Location for the list of proxy types supported
get_country_shortReturn the ISO3166-1 country code (2-digits) of the proxy.
get_country_longReturn the ISO3166-1 country name of the proxy.
get_regionReturn the ISO3166-2 region name of the proxy. Please visit ISO3166-2 Subdivision Code for the information of ISO3166-2 supported
get_cityReturn the city name of the proxy.
get_ispReturn the ISP name of the proxy.
get_domainReturn the domain name of proxy's IP address or domain name.
get_usage_typeReturn the ISP's usage type of proxy's IP address or domain name. Please see Usage Type for details.
get_asnReturn the autonomous system number (ASN) of proxy's IP address or domain name.
get_as_nameReturn the autonomous system (AS) name of proxy's IP address or domain name.
get_last_seenReturn the last seen days ago value of proxy's IP address or domain name.

要求

  1. Python 2.2及以上版本

安装

  1. 解开包裹。
  2. 执行python setup.py build
  3. 执行python setup.py安装

要安装此模块,请键入以下内容(对于PYPI):

pip install IP2Proxy

用法

importIP2Proxydb=IP2Proxy.IP2Proxy()# open IP2Proxy BIN database for proxy lookupdb.open("IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN.BIN")# get versioning informationprint('Module Version: '+db.get_module_version())print('Package Version: '+db.get_package_version())print('Database Version: '+db.get_database_version())# individual proxy data checkprint('Is Proxy: '+str(db.is_proxy("4.0.0.47")))print('Proxy Type: '+db.get_proxy_type("4.0.0.47"))print('Country Code: '+db.get_country_short("4.0.0.47"))print('Country Name: '+db.get_country_long("4.0.0.47"))print('Region Name: '+db.get_region("4.0.0.47"))print('City Name: '+db.get_city("4.0.0.47"))print('ISP: '+db.get_isp("4.0.0.47"))print('Domain: '+db.get_domain("4.0.0.47"))print('Usage Type: '+db.get_usage_type("4.0.0.47"))print('ASN: '+db.get_asn("4.0.0.47"))print('AS Name: '+db.get_as_name("4.0.0.47"))print('Last Seen: '+db.get_last_seen("4.0.0.47"))# single function to get all proxy data returned in arrayrecord=db.get_all("4.0.0.47")print('Is Proxy: '+str(record['is_proxy']))print('Proxy Type: '+record['proxy_type'])print('Country Code: '+record['country_short'])print('Country Name: '+record['country_long'])print('Region Name: '+record['region'])print('City Name: '+record['city'])print('ISP: '+record['isp'])print('Domain: '+record['domain'])print('Usage Type: '+record['usage_type'])print('ASN: '+record['asn'])print('AS Name: '+record['as_name'])print('Last Seen: '+record['last_seen'])# close IP2Proxy BIN databasedb.close()

代理类型

Proxy TypeDescription
VPNAnonymizing VPN services.
TORTor Exit Nodes.
PUBPublic Proxies.
WEBWeb Proxies.
DCHHosting Providers/Data Center.
SESSearch Engine Robots.

使用类型

Usage TypeDescription
COMCommercial
ORGOrganization
GOVGovernment
MILMilitary
EDUUniversity/College/School
LIBLibrary
CDNContent Delivery Network
ISPFixed Line ISP
MOBMobile ISP
DCHData Center/Web Hosting/Transit
SESSearch Engine Spider
RSVReserved

支架

电子邮件:support@ip2location.com。 网址:https://www.ip2location.com

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java调用外部进程exe   java跨源请求阻止Spring REST服务+AJAX   运行Eclipse创建的JAR时未显示java图像   带有自定义适配器的TimerTask期间的java更新列表视图   Java Netbeans 7.01中的swing注册表单空指针异常   java如何向所有HttpClient请求方法添加参数?   为什么在将json映射到JavaBean的过程中,Spring MVC将参数[“”]转换为[null]?   创建名为“messageDispatcher”的bean时发生java错误   java Apache骆驼线程JDBC   java Spring引导请求添加bean,即使存在   java如何以正确的方式编写单例?   JavaSpringBoot试图使用@JsonTest注释在测试中创建mongo存储库   java Android将gmt时间转换为可读日期   java“Serializable无法解析为类型”   spring我可以在Java注释中使用ScopedProxy模式时访问JobExecutionContext吗   java slf4j apache tomcat eclipse   通过HashMap的java循环   java无法在两个活动之间更改TextView?