In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to use java to obtain the administrative region of the National Bureau of Statistics. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1. The program can take the required provinces, cities, counties, townships (streets) and village (neighborhood) committees according to the needs, and the code is 12 digits.
2. The acquired year can be changed.
3. It can be written into the database according to the requirements, easy to use, and can be updated and maintained once a year.
4. The National Bureau of Statistics has access restrictions, so it is not suitable to obtain all the data of the whole country at once. It is suggested that it can be divided into provinces and obtained by stages.
The implementation code is as follows:
Import java.io.BufferedReader
Import java.io.InputStreamReader
Import java.net.CookieHandler
Import java.net.CookieManager
Import java.net.CookiePolicy
Import java.net.HttpURLConnection
Import java.net.URL
Import java.nio.charset.Charset
Import java.util.List
/ * *
Obtaining administrative divisions from the National Bureau of Statistics
National Bureau of Statistics-NBOS (National Bureau of Statistics)
, /
/ * param args * @ throws Exception * / public static void main (String [] args) throws Exception {String url = baseUrl + "index.html"; / / if you need to set the agent / / initProxy ("xx.xx.xx.xx", "xx"); String str = getContent (url). ToUpperCase () String [] arrs = str.split (") + 2, s.indexOf ("); if (! ") Beijing ".equals (name)) {continue;} System.out.println (" acquisition province: "+ name); readShi (aForce name) * @ param list * @ throws Exception * / public static void readShi (String url,String name) throws Exception {String content = getContent (baseUrl+url) .toUpperCase (); String [] citys = content.split ("CITYTR"); / /'> 110100000000 municipal district ") + 2, strs[ si] .indexOf (")) System.out.println ("cityCode:" + cityCode);} else {cityName = name+ strs[ si] .substring (strs[ si] .indexOf ("" > ") + 2, strs[ si] .indexOf (")); System.out.println (" get the city: "+ cityName) }} readXian (cityUrl.substring (0, cityUrl.indexOf ("/") + 1), cityUrl,cityName);}} / * * read county data * @ param url * @ throws Exception * / public static void readXian (String prix,String url,String cityName) throws Exception {String content = getContent (baseUrl+url). ToUpperCase () String [] citys = content.split ("COUNTYTR"); for (int iTunes 1; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.