如果有人能帮忙的话。我正在创建一个用于商业目的的数据库,并从一个由java脚本编写的web中抓取信息。我可以刮掉信息,但不能剪掉我想要的数据。下面是全部信息。任何人只知道如何输出,比如说-
"mainInformation":{"fundCode":"U44437","fundCodeDisplay":"(U44437)","fundName":"JPM ASIA PACIFIC INCOME A (MTH) (USD-CASH)"收集的数据是-
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释
* "<html><body><p>{"detailInformation":{"feeInfoSubFee":"5.00%","feeInfoSwitchingFee":"1.00%","feeInfoManagementFee":"1.500% p.a","feeInfoRedemptionFee":"0.00%","feeInfoPerformanceFee":"-","feeInfoIncentiveFee":"-","feeInfoMaxTrailerFee":"60.00%","feeInfoMaxTrailerRemarks":"-","invObjStrategy":"To provide income and long term capital growth by investing primarily in income generating securities of countries in the Asia Pacific region (excluding Japan).\r\nAt least 67% of the Fund’s assets (excluding cash and cash equivalents) will be invested in equity securities, debt securities, convertible securities and Real Estate Investment Trusts (“REITS”). Issuers of these securities will be companies that are domiciled in, or carrying out the main part of their economic activity in, the Asia Pacific region (excluding Japan) or governments or their agencies of countries in the Asia Pacific region (excluding Japan).\r\nThe Fund may invest a significant proportion of its assets in below investment grade and unrated debt securities. There are no credit quality or maturity restrictions with respect to the debt securities in which the Fund may invest. The Fund invests in financial derivative instruments in a limited extent for investment purpose.","portfolioDate":"31-07-2018","assetAllocationList":[{"assetAllocationName":"Stock","assetAllocationValue":"60.33"},{"assetAllocationName":"Bond","assetAllocationValue":"34.50"},{"assetAllocationName":"Cash","assetAllocationValue":"4.66"},{"assetAllocationName":"Other","assetAllocationValue":"0.51"}],"geoAllocationChart":"/HaseChartCenter/BasePieChart.aspx?p_ImageType=PortfolioAllocationPie&p_Data=1.28259,3.29955,14.14580,40.01720,41.25486&p_Legend=United States,United Kingdom,Australasia,Asia - Developed,Asia - Emerging&p_Lang=0L00000122","sectorAllocationChart":"/HaseChartCenter/BasePieChart.aspx?p_ImageType=PortfolioAllocationPie&p_Data=0.59690,0.94111,23.09932,9.04259,1.35411,4.83165,2.15222,2.94322,6.94703,8.42347&p_Legend=Basic Materials,Consumer Cyclical,Financial Services,Real Estate,Consumer Defensive,Utilities,Communication Services,Energy,Industrials,Technology&p_Lang=0L00000122","bondSectorBreakdownPieChart":"/HaseChartCenter/BasePieChart.aspx?p_ImageType=PortfolioAllocationPie&p_Data=4.23195,30.86812,4.56831&p_Legend=Government,Corporate,Cash and Equivalents&p_Lang=0L00000122","fundGrowthChart":"/HaseChartCenter/MSChart.aspx?p_ImageType=FundGrowthLine&fundCode=U44437","historicalPriceChart":"/HaseChartCenter/MSChart.aspx?p_ImageType=HistoricalPriceLine&fundCode=U44437","totalNumOfStockHldg":"71","totalNumOfBondHldg":"258","topHoldingDate":"-","topHoldingList":[{"holdingName":"Taiwan Semiconductor Manufacturing Co Ltd","netAssetPercentage":"2.82"},{"holdingName":"JPM US Dollar Liquidity X (dist.)","netAssetPercentage":"3.66"},{"holdingName":"Korea Electric Power Corp","netAssetPercentage":"2.64"},{"holdingName":"China Life Insurance Co Ltd H Shares","netAssetPercentage":"2.23"},{"holdingName":"Samsung Electronics Co Ltd","netAssetPercentage":"1.99"},{"holdingName":"HSBC Holdings PLC","netAssetPercentage":"1.99"},{"holdingName":"United Overseas Bank Ltd","netAssetPercentage":"1.90"},{"holdingName":"BOC Hong Kong Holdings Ltd","netAssetPercentage":"1.86"},{"holdingName":"PetroChina Co Ltd H","netAssetPercentage":"1.81"},{"holdingName":"DBS Group Holdings Ltd","netAssetPercentage":"1.70"}],"perHistoryDate":"31-07-2018","returnCumPerList":[{"cumPerformanceReturnYTD":"-3.66","cumPerformanceReturn1Week":"-0.95","cumPerformanceReturn1Month":"0.86","cumPerformanceReturn3Month":"-3.14","cumPerformanceReturn6Month":"-4.27","calPerformanceReturn1Y":"","calPerformanceReturn2Y":"","calPerformanceReturn3Y":"","calPerformanceReturn4Y":"","calPerformanceReturn5Y":"","pastPerformanceReturn1Y":"","pastPerformanceReturn3Y":"","pastPerformanceReturn5Y":"","pastPerformanceReturn10Y":"","pastPerformanceReturn15Y":""}],"returnCumAveList":[{"cumPerformanceReturnYTD":"-6.13","cumPerformanceReturn1Week":"-1.89","cumPerformanceReturn1Month":"-1.38","cumPerformanceReturn3Month":"-5.31","cumPerformanceReturn6Month":"-7.19","calPerformanceReturn1Y":"","calPerformanceReturn2Y":"","calPerformanceReturn3Y":"","calPerformanceReturn4Y":"","calPerformanceReturn5Y":"","pastPerformanceReturn1Y":"","pastPerformanceReturn3Y":"","pastPerformanceReturn5Y":"","pastPerformanceReturn10Y":"","pastPerformanceReturn15Y":""}],"returnPastYearPerList":[{"cumPerformanceReturnYTD":"","cumPerformanceReturn1Week":"","cumPerformanceReturn1Month":"","cumPerformanceReturn3Month":"","cumPerformanceReturn6Month":"","calPerformanceReturn1Y":"","calPerformanceReturn2Y":"","calPerformanceReturn3Y":"","calPerformanceReturn4Y":"","calPerformanceReturn5Y":"","pastPerformanceReturn1Y":"-0.45","pastPerformanceReturn3Y":"3.98","pastPerformanceReturn5Y":"4.46","pastPerformanceReturn10Y":"-","pastPerformanceReturn15Y":"-"}],"returnPastYearAvgList":[{"cumPerformanceReturnYTD":"","cumPerformanceReturn1Week":"","cumPerformanceReturn1Month":"","cumPerformanceReturn3Month":"","cumPerformanceReturn6Month":"","calPerformanceReturn1Y":"","calPerformanceReturn2Y":"","calPerformanceReturn3Y":"","calPerformanceReturn4Y":"","calPerformanceReturn5Y":"","pastPerformanceReturn1Y":"-1.24","pastPerformanceReturn3Y":"3.85","pastPerformanceReturn5Y":"3.09","pastPerformanceReturn10Y":"3.47","pastPerformanceReturn15Y":"6.21"}],"returnYearPerList":[{"cumPerformanceReturnYTD":"","cumPerformanceReturn1Week":"","cumPerformanceReturn1Month":"","cumPerformanceReturn3Month":"","cumPerformanceReturn6Month":"","calPerformanceReturn1Y":"14.19","calPerformanceReturn2Y":"6.16","calPerformanceReturn3Y":"-3.05","calPerformanceReturn4Y":"7.11","calPerformanceReturn5Y":"3.56","pastPerformanceReturn1Y":"","pastPerformanceReturn3Y":"","pastPerformanceReturn5Y":"","pastPerformanceReturn10Y":"","pastPerformanceReturn15Y":""}],"returnYearAveList":[{"cumPerformanceReturnYTD":"","cumPerformanceReturn1Week":"","cumPerformanceReturn1Month":"","cumPerformanceReturn3Month":"","cumPerformanceReturn6Month":"","calPerformanceReturn1Y":"21.66","calPerformanceReturn2Y":"1.87","calPerformanceReturn3Y":"-4.60","calPerformanceReturn4Y":"3.16","calPerformanceReturn5Y":"2.93","pastPerformanceReturn1Y":"","pastPerformanceReturn3Y":"","pastPerformanceReturn5Y":"","pastPerformanceReturn10Y":"","pastPerformanceReturn15Y":""}],"returnPerValue":null,"fundLaunchDate":"25-05-2012","fundInvMarketSector":"Asia Allocation","fundType":"Balanced","hsFundType":"","fundDealingFreqeuncy":"One Dealing Session per Dealing Day/HKT 16:00","fundDealingCutoffTime":"","fundHouse":"J.P. Morgan Asset Management","fundMorningstarRatingDate":"31-7-2018","fundOverallRating":"4","threeYRating":"3","fiveYRating":"4","tenYRating":"","equValPE":"11.39","equValPC":"4.16","equValPB":"1.07","fundVolDate":"31-7-2018","fundVolOneYearSR":"-0.07","fundVolOneYearSD":"7.58","fundVolOneYearMR":"-0.45%","fundVolThreeYearSR":"0.41","fundVolThreeYearSD":"8.36","fundVolThreeYearMR":"3.98%","fundManager":[{"fundManager":"Jeffrey Roskell","fundManagerStartDate":"01-02-2010","fundBiography":"Jeffrey Roskell, managing director, is a regional specialist for Asia Pacific inc-Japan equities with the Emerging Markets and Asia Pacific (EMAP) Equities Team based in Hong Kong. He joined the Firm in 1997 as an investment manager with the Global Equities Team (previously known as the Global Portfolios Group) in Hong Kong and then transferred to manage Asia specific portfolios in 2000. He joined the industry in 1992 as a graduate trainee with Prudential Portfolio Managers Limited in London and subsequently specialized in managing portfolios invested in Continental European equities. Jeffrey obtained an M.A. in Economics from Cambridge University and an Investment Management Certificate from the London Business School."},{"fundManager":"Julie Ho","fundManagerStartDate":"01-01-2014","fundBiography":"Julie Ho, executive director, is a regional specialist for Asia Pacific ex-Japan equities with the Emerging Markets and Asia Pacific (EMAP) Equities Team based in Hong Kong. Julie joined the Firm in 2005 and was transferred to the team in 2013 from the U.S. Equity Group where she was a research analyst covering the U.S. and Canadian REIT sectors. Prior to that, she worked as a research assistant on the REITs sector and as an investment assistant in the U.S. Active Equity Group. Julie graduated Phi Beta Kappa from Brown University with a B.S. in Biology and a B.A. in Economics. She is also a CFA Charterholder."},{"fundManager":"Shaw Yann Ho","fundManagerStartDate":"01-01-2014","fundBiography":"-"},{"fundManager":"Selina Yu","fundManagerStartDate":"26-02-2018","fundBiography":"-"},{"fundManager":"Ruben Lienhard","fundManagerStartDate":"01-06-2018","fundBiography":"-"}],"performanceDataShown":true,"performanceStartYear":"2017","withPromotion":"Y","fundGroupId":"Balanced","hasMangFee":"","isIpower":"Y"},"dividendInformation":{"divInfoDate":"","divInfoCurrency":"USD","divInfoFrequency":"Monthly","divInfoYield":"4.55%","divInfoLastDividend":"0.437","divInfoLastDate":"08-08-2018"},"mainInformation":{"fundCode":"U44437","fundCodeDisplay":"(U44437)","fundName":"JPM ASIA PACIFIC INCOME A (MTH) (USD-CASH)","fundClass":"A","fundCurrency":"USD","nav":"111.24","dailyChangeAmount":"","dailyChangePercentage":"0.21%","lastDate":"17-08-2018","fundSize":"2,758,268,955.00","fundSizeCurrency":"USD","riskLevel":"3","investmentTenor":"≥ 1 Year(s) 0 Month(s)","dividendPolicy":"IC","objType":"2","mSOverallRating":"4","enbaleSubscibe":"Y","invType":"LPS","isPIFund":"N","isDerivative":"","isRQFII":"N","isHighYieldBond":"N","isFDIS":"N","isNewFDIS":"N","isMRF":"N","docARFilePath":"/ODSRevamp/0C00006C50/ODAR/0C00006C50ODAR408527E_20170630.PDF","docIRFilePath":"/ODSRevamp/0C00006C50/ODIR/0C00006C50ODIR434125E_20171231.PDF","docEMFilePath":"/ODSRevamp/0C00006C50/ODEM/0C00006C50ODEM471139E_20180801.PDF","docMMFilePath":"/ODSRevamp/0C00006C50/ODMM/0C00006C50ODMM473339B_20180801.PDF","docFSFilePath":"/ODSRevamp/0C00006C50/ODFS/0C00006C50ODFS469591E_20180630.PDF","otherFundList":[{"otherFundCode":"U85126","otherFundName":"JPM ASIA PACIFIC INCOME A (DIST) (USD)","otherFundCurrency":"USD","otherFundClass":"A","otherFundInvType":"LPS"},{"otherFundCode":"U44438","otherFundName":"JPM ASIA PACIFIC INCOME A (MTH) (HKD-CASH)","otherFundCurrency":"HKD","otherFundClass":"A","otherFundInvType":"LPS"},{"otherFundCode":"U44559","otherFundName":"JPM ASIA PACIFIC INCOME A (IRC) (AUD HEDGED) (MTH-CASH)","otherFundCurrency":"AUD","otherFundClass":"A","otherFundInvType":"LPS"},{"otherFundCode":"U44561","otherFundName":"JPM ASIA PACIFIC INCOME A (IRC) (CAD HEDGED) (MTH-CASH)","otherFundCurrency":"CAD","otherFundClass":"A","otherFundInvType":"LPS"},{"otherFundCode":"U44557","otherFundName":"JPM ASIA PACIFIC INCOME A (IRC) (EUR HEDGED) (MTH-CASH)","otherFundCurrency":"EUR","otherFundClass":"A","otherFundInvType":"LPS"},{"otherFundCode":"U44558","otherFundName":"JPM ASIA PACIFIC INCOME A (IRC) (GBP HEDGED) (MTH-CASH)","otherFundCurrency":"GBP","otherFundClass":"A","otherFundInvType":"LPS"},{"otherFundCode":"U44560","otherFundName":"JPM ASIA PACIFIC INCOME A (IRC) (NZD HEDGED) (MTH-CASH)","otherFundCurrency":"NZD","otherFundClass":"A","otherFundInvType":"LPS"}],"fundSizeDate":"31-07-2018","categoryId":"EUCA000559","retLastDate":"17-08-2018"},"majorInformation":{"sectorName":"Equity/ Bond Balanced","dealingRestriction":"Canadian Resident or US Citizen/Resident"},"uintPriceInformation":{"unitPriceDate":"17-08-2018","unitPriceNav":"111.24","unitPriceBid":"","unitPriceOffer":"","unitPriceChangePercent":"0.21%","unitPriceCurrency":"USD","unitPriceWeeks52High":"110.61-124.32","unitPriceHisChart":""}}</p></body></html>"
*/发布于 2018-08-19 08:37:19
import json
import urllib.request
request = urllib.request.Request('https://rbwm-api.hsbc.com.hk/pws-hk-hase-fsm-papi-prod-proxy/v1/Funds/U44437?targetCurrency=&isPIFund=N%27')
resp = urllib.request.urlopen(request)
data = json.loads(resp.read())
mi=data['mainInformation']
print(mi['fundCode'], mi['fundName'])发布于 2018-08-19 08:09:50
我认为问题是将json字符串转换为python字典,您可以使用json模型。
下面是参考代码,json.loads是关键方法:
#!/usr/bin/python3.6
# -*- coding: utf-8 -*-
import json
# data.txt: full json text
f = open("./data.txt", 'r')
full_txt = f.read()
f.close()
# decode json text to python dictionary
full_txt = json.loads(full_txt, encoding='utf-8', strict=False)
# do some thing just like operate python dictionary
for k,v in full_txt.items():
print(k,v)https://stackoverflow.com/questions/51915453
复制相似问题