In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to install and use jsonpath". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install and use jsonpath.
Installation
#! / usr/bin/env python#-*-coding:utf-8-*-import urllib2# json parsing library corresponds to the parsing syntax of lxmlimport json# json, corresponding to xpathimport jsonpathurl = "http://www.lagou.com/lbs/getAllCitySearchLabels.json"headers = {" User-Agent ":" Mozilla/5.0 (Windows NT 10.0; Win64) X64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36 "} request = urllib2.Request (url, headers=headers) response = urllib2.urlopen (request) # extract the contents of the json file The returned format is the string html = response.read () # converts a string in json form into a Unicode string in python form unicodestr = json.loads (html) # Python form list city_list = jsonpath.jsonpath (unicodestr, "$.. name") # for item in city_list:# print item# dumps () default Chinese is ascii encoding format, ensure_ ascii defaults to Ture# disable ascii encoding format, and the returned Unicode string Easy to use array = json.dumps (city_list, ensure_ascii=False) # json.dumps (city_list) # array = json.dumps (city_list) with open ("city.json", "w") as f: f.write (array.encode ("utf-8")) so far, I believe you have a deeper understanding of "how to install and use jsonpath", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.