Получаю ответ от сервера Код: {"data":[{"url":"domen.tld","domain_auth":"1.00","page_auth":"1.00","m_rank":null,"site":"domen.tld","ip":"0.0.0.0","region":""}],"urls":["domen.tld"]} Как получить данные DA, PA и другие?
Здравствуйте. В шаблонизаторе есть специальный инструмент для разбора JSON/ Более подробно по ссылке https://a-parser.com/wiki/template-tools/#tools-parsejson-разбор-json-структур
Я дико извиняюсь, но мне так и не удалось разобраться в документации по ссылке выше. Пробую разобрать такой json: Код: { "ServerVersion" : "1.0.6675.26923", "QueriedURLsMayExist" : 0, "DataTables" : { "Results" : { "Headers" : { "TopicsCount" : 3, "MaxTopicsSubDomain" : 20, "MaxTopicsRootDomain" : 30, "MaxTopicsURL" : 10 }, "Data" : [ { "GetTopBackLinksAnalysisResUnitsCost" : 5000, "RefDomainTypeDirect" : "10482", "NonUniqueLinkTypeHomepages" : "6839", "ExtBackLinksGOV" : 852, "LanguageDesc" : "English,German,French,Spanish/Castilian,Italian,Japanese,Polish,Chinese,Russian,Portuguese", "TopicalTrustFlow_Topic_0" : "Computers/Internet/Web Design and Development", "NonUniqueLinkTypeProtocolHTTPS" : "2206466", "TopicalTrustFlow_Value_1" : 27, "TopicalTrustFlow_Topic_1" : "Computers/Computer Science/Distributed Computing", "LanguagePageRatios" : "76.6,5.6,3,2.6,2,1.7,1.6,1.6,1.6,1.6", "ACRank" : -1, "NonUniqueLinkTypeRedirect" : "385419", "NonUniqueLinkTypeImageLink" : "1229316", "TopicalTrustFlow_Topic_2" : "Reference/Education", "TopicalTrustFlow_Value_0" : 32, "CrawledURLs" : 555455, "RefLanguageDesc" : "English,German,French,Spanish/Castilian,Czech,Japanese,Polish,Russian", "LastCrawlResult" : "", "LanguageTotalPages" : 222172, "CrawledFlag" : "False", "TrustMetric" : 37, "TopicalTrustFlow_Value_2" : 25, "RefDomainTypeFollow" : "13568", "RootDomainIPAddress" : "212.74.50.1", "RefDomainsGOV" : 6, "NonUniqueLinkTypeFrame" : "1964", "RefLanguage" : "en,de,fr,es,cs,ja,pl,ru", "RefDomains" : 16324, "OutLinksInternal" : "95", "OutDomainsExternal" : "7", "OutLinksPages" : "243246", "FinalRedirectResult" : "", "Status" : "Found", "ExtBackLinksEDU" : 2376, "NonUniqueLinkTypeDeleted" : "581804", "RefDomainsEDU_Exact" : 18, "RefDomainTypeProtocolHTTPS" : "6404", "ResultCode" : "OK", "AnalysisResUnitsCost" : 6835422, "ExtBackLinks" : 6835422, "ItemNum" : 0, "DownloadRefDomainBacklinksAnalysisResUnitsCost" : 376480, "DownloadBacklinksAnalysisResUnitsCost" : 16148092, "RefDomainsGOV_Exact" : 1, "RedirectTo" : "", "IndexedURLs" : 9312670, "RefLanguageConfidence" : "98,55,82,59,81,70,90,70", "ExtBackLinksGOV_Exact" : 1, "ItemType" : 1, "RefDomainTypeLive" : "14946", "RefDomainTypeHomepageLink" : "926", "NonUniqueLinkTypeIndirect" : "1244307", "LastCrawlDate" : "", "LanguageConfidence" : "97,58,60,63,56,76,76,67,62,77", "Title" : "Majestic®: Marketing Search Engine and SEO Backlink Checker", "RefLanguageTotalPages" : 6189159, "NonUniqueLinkTypeNoFollow" : "1002798", "RefSubNets" : 8485, "NonUniqueLinkTypeTextLink" : "5725703", "OutLinksExternal" : "7", "CitationFlow" : 66, "RefIPs" : 12973, "Item" : "majestic.com", "RedirectFlag" : "False", "Language" : "en,de,fr,es,it,ja,pl,zh,ru,pt", "RefDomainsEDU" : 92, "LastSeen" : "", "RefLanguagePageRatios" : "80.7,11.4,1.8,1.7,1.3,1.2,0.6,0.1", "TotalNonUniqueLinks" : "7342402", "TrustFlow" : 37, "ExtBackLinksEDU_Exact" : 54 } ] } }, "QueriedURLs" : 0, "IndexType" : 1, "ServerBuild" : "2018-04-11 15:57:27", "ServerName" : "ECHOLIMA", "FullError" : "", "FirstBackLinkDate" : "2017-12-18", "ErrorMessage" : "", "IndexBuildDate" : "2018-04-19 03:51:44", "Code" : "OK", "UniqueIndexID" : "20180419035144-FRESH", "QueriedRootDomains" : 1, "MostRecentBackLinkDate" : "2018-04-17", "QueriedSubDomains" : 0 } Пробую такой Result format: Код: [% json = tools.parseJSON(data); json.$DataTables.Results.Data.0.TopicalTrustFlow_Topic_0 %] [% data.substr(0,64) %] На выходе получаю: {"Code":"OK","ErrorMessage":"","FullError":"","FirstBackLinkDate Подскажите, плиз, как правильно получить из этого json данные в csv-формате: TrustFlow, CitationFlow, TopicalTrustFlow_Topic_0,TopicalTrustFlow_Value_0
Здравствуйте. Попробуйте так. Код: json.DataTables.Results.Data.0.TopicalTrustFlow_Topic_0 То есть знак доллара лишний. И Код: [% data.substr(0,64) %] тут ни к чему.