.StreamReader sReader; 06. string strReturn = string.Empty; 07. 08. try 09. { 10. objWebReq = System.Net.WebRequest.Create(objUrl); 11. objResp = objWebReq.GetResponse(); 12. 13. sReader = new System.IO.StreamReader(objResp.GetResponseStream()); 14. strReturn = sReader.ReadToEnd(); 15. 16. sReader.Close(); 17. objResp.Close(); 18. } 19. catch (Exception ex) 20. { 21. } 22. finally 23. { 24. objWebReq = null; 25. } 26. 27. return strReturn; 28.} private string GetMaxMindOmniData(string IP) { System.Uri objUrl = new System.Uri("http://geoip.maxmind.com/e?l=YOUR_LICENSE_KEY&i=" + IP); System.Net.WebRequest objWebReq; System.Net.WebResponse objResp; System.IO.StreamReader sReader; string strReturn = string.Empty;
try { objWebReq = System.Net.WebRequest.Create(objUrl); objResp = objWebReq.GetResponse();
sReader = new System.IO.StreamReader(objResp.GetResponseStream()); strReturn = sReader.ReadToEnd();
sReader.Close(); objResp.Close(); } catch (Exception ex) { } finally { objWebReq = null; }
return strReturn; } Ruby版本:
[ruby] view plaincopyprint? 01.#!/usr/bin/env ruby 02. 03.require 'csv' 04.require 'net/http' 05.require 'open-uri' 06.require 'optparse' 07.require 'uri' 08. 09.fields = [:country_code, 10. :country_name, 11. :region_code, 12. :region_name, 13. :city_name, 14. :latitude, 15. :longitude, 16. &nb
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
|