Programing

API를 통해 내 공용 IP 받기

lottogame 2020. 10. 24. 09:23
반응형

API를 통해 내 공용 IP 받기


프로그램 내에서 내 공개 IP를 가져 오는 대기업의 공개 API가 있습니까?

나는 http://ip-address.domaintools.com/myip.xml정확히 내가 원하는 것을 찾았 지만 불행히도 urllib사용자 에이전트를 스푸핑하지 않는 한 Python 과 다른 많은 http 라이브러리를 차단합니다 (그 모든 것을 API라고 할 수 없습니다).

문제는 잠재적으로 오픈 소스 라이브러리에이 데이터가 필요하므로 규칙을 따라야한다는 것입니다. 나는 또한 내가 맘대로 할 수 있다는 것을 알고 print $_SERVER[REMOTE_ADDR]있지만 내 라이브러리를 사용하는 모든 사람에게 트래픽을 서버 화하고 싶지는 않습니다.

그렇다면 위의 URL과 비슷하지만 로봇을 허용하는 실제 API가 있습니까?


대기업은 아니지만이 모든 것이 작동합니다.

curl icanhazip.com
curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
host -t a dartsclink.com | sed 's/.*has address //'
curl curlmyip.com
curl ifconfig.me # this has a lot of different alternatives too, such as ifconfig.me/host

출처


내 서비스 http://ipinfo.io 에서 IP 및 기타 정보를 얻을 수 있습니다 .

$ curl ipinfo.io
{
  "ip": "67.188.232.131",
  "hostname": "c-67-188-232-131.hsd1.ca.comcast.net",
  "city": "Mountain View",
  "region": "California",
  "country": "US",
  "loc": "37.385999999999996,-122.0838",
  "org": "AS7922 Comcast Cable Communications, Inc.",
  "phone": 650
}

IP 만 원하는 경우 :

$ curl ipinfo.io/ip
67.188.232.131

다른 필드에서도 작동합니다. 예 :

$ curl ipinfo.io/org
AS7922 Comcast Cable Communications, Inc.

자세한 내용은 http://ipinfo.io/developers 에서 확인할 수 있습니다.


latlong, country, city, user-agent와 같은 세부 정보를 제공하는 json 형식 :

https://www.trackip.net/ip?json

또는

https://www.trackip.net/ip


나는 이것을 사용하고 기억하기 쉽고 다른 것보다 짧습니다.

$ curl ifconfig.me

PROTIP : 쉘 스크립트에서 curl을 사용하는 경우 -s옵션 을 사용해야 하며 그렇지 않으면 다운로드 진행률 테이블을 인쇄합니다.

$ echo `curl -s ifconfig.me`


다음과 같은 작업을 수행하는 웹 서비스 API를 사용할 수 있습니다.

see example of service: http://ip-api.com and usage: http://whatmyip.info

행운을 빕니다!!!


이 API를 사용하여 IP 정보에 액세스합니다.

http://cms.javabrown.com/jws/ws.php?service=IpService

JSONP :

http://cms.javabrown.com/jws/ws.php?service=IpService&callback=?


Yes you may try out with whoisthisip.com

http://whoisthisip.com/HRAS/ Register to whoisthisip.com to get a website's IP address information such as city location, country location and domain name.

Once signed in, you will be given a reference code and a url to view and get the information of IP address for the website you registered.


If you cannot install curl in your system wget variant would be:

wget -qO- curlmyip.com

참고URL : https://stackoverflow.com/questions/3097589/getting-my-public-ip-via-api

반응형