How to get <img> src value from xml file? - javascript

I am trying to create a simple rss feed website.
I can get a few of rss feeds by just doing this:
let article = {
'title': item.title,
'image': item.image.url,
'link': item.link,
'description': item.description,
}
Title and link work for most of rss feeds, but image and description do not.
Since a lot of rss fees has image as html inside of description like this:
{ title: 'The Rio Olympics Are Where TV Finally Sees the Future',
description: '<div class="rss_thumbnail"><img src="http://www.wired.com/wp-content/uploads/2016/08/GettyImages-587338962-660x435.jpg" alt="The Rio Olympics Are Where TV Finally Sees the Future" /></div>Time was, watching the Olympics just meant turning on your TV. That\'s changed—and there\'s no going back. The post The Rio Olympics Are Where TV Finally Sees the Future appeared first on WIRED.',...
How can I get image's url from it?
EDIT:
http.get("http://www.wired.com/feed/"...
.on('readable', function() {
let stream = this;
let item;
while( item = stream.read()){
let article = {
'title': item.title,
'image': item.image.url,
'link': item.link,
'description': item.description,
}
news.push(article);
}
})
this is some of my codes, and basically I am trying to get image url from Wired rss.
If I user 'image': item.image.url, it does not work. So what should I change it to?

use xml2js for converting xml to json
var parseString = require('xml2js').parseString;
var xml = '<img title=\'A San Bernardino County Fire Department firefighter watches a helitanker make a water drop on a wildfire, seen from Cajon Boulevard in Devore, Calif., Thursday, Aug. 18, 2016. (David Pardo/The Daily Press via AP)\' height=\'259\' alt=\'APTOPIX California Wildfires\' width=\'460\' src=\'http://i.cbc.ca/1.3730399.1471835992!/cpImage/httpImage/image.jpg_gen/derivatives/16x9_460/aptopix-california-wildfires.jpg\' />';
parseString(xml, function (err, result) {
console.log(JSON.stringify(result, null, 4));
console.log(result["img"]["$"]["src"]);
});

Use regex of string:
var res = description.match(/src=.*\.(jpg|jpeg|png|gif)/gi);
Fiddle Demo

One idea would be to use regular expressions. For ex:
var re = /(src=)(\\'htt.*\\')/g
var img_string = "your image tag string"
var match = re.exec(img_string)
var result = match[1]

You can use DOMDocument parser to get Image source.
$html = "<img title=\'A San Bernardino County Fire Department firefighter watches a helitanker make a water drop on a wildfire, seen from Cajon Boulevard in Devore, Calif., Thursday, Aug. 18, 2016. (David Pardo/The Daily Press via AP)\' height=\'259\' alt=\'APTOPIX California Wildfires\' width=\'460\' src=\'http://i.cbc.ca/1.3730399.1471835992!/cpImage/httpImage/image.jpg_gen/derivatives/16x9_460/aptopix-california-wildfires.jpg\' />";
$doc = new DOMDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$src = $xpath->evaluate("string(//img/#src)"); # "/images/image.jpg"

Related

How to extract email addresses from my string result and save them in a txt file one per line

I'm fetching data from different sources and the output string looks like the following:
"addressId":"132234","businessEntryCount":2026},{"district":"Nordend-West","districtSlug":"frankfurt-am-main-nordend-west","addressId":"132232","businessEntryCount":1925}],"generated":"2022-01-23 19:35:43.469","grisuLocation":null,"district":null,"geo":null};
kt.Data.SearchResult.distanceLocation = "Frankfurt am Main";
kt.Data.SearchResult.distanceStreetnumber = "";
kt.Service.citySlug = 'frankfurt';
kt.Data.what = 'Handwerker';
kt.Data.where = 'Frankfurt am Main';
kt.Data.trade = 'Maler';
{"#context":"http:\/\/schema.org","#type":"SearchResultsPage","mainEntity":{"#type":"ItemList","itemListElement":[{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Dachdecker Olaf Pocklitz","url":"http:\/\/www.test.de","email":"test#t-online.de","address":{"#type":"PostalAddress","postalCode":"65931","addressLocality":"Frankfurt","addressRegion":"Hessen",
The above string content is my data result. I want to have only all the email addresses left to save them in a file. In the above example it would be test#t-online.de and if we have more than one email address, then I want the second email address in a new line. Im struggling how to perfectly filter them out and afterwards save them one by line. I already made it work to save it but I don't know how to only get the email address out of it:
console.log('received data: ' + data)
fs.writeFileSync('./results/test.json', data)
EDIT:
This is my code so far:
var matches = data.match(/\"mainEntity":{"(.*?)\"}/);
var preResult = [matches]
//.itemListElement[0].item.email
console.log('received data: ' + preResult)
fs.writeFileSync('./results/test.json', preResult)
and my result but im not able to access the email:
"mainEntity":{"#type":"ItemList","itemListElement":[{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Dachdecker Olaf test","url":"http:\/\/www.test.de","email":"test#t-online.de","address":{....
With this selector: element.mainEntity.itemListElement[0].item.email
const element = {
"#context":"http:\/\/schema.org",
"#type":"SearchResultsPage",
"mainEntity":{
"#type":"ItemList",
"itemListElement":[
{
"#type":"ListItem",
"item":{
"#type":"LocalBusiness",
"name":"Dachdecker Olaf Pocklitz",
"url":"http:\/\/www.test.de",
"email":"test#t-online.de",
"address": ""
}
}
]
}}
console.log(element.mainEntity.itemListElement[0].item.email)
Update
d = {"#context":"http:\/\/schema.org","#type":"SearchResultsPage","mainEntity":{"#type":"ItemList","itemListElement":[{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Dachdecker Olaf Pocklitz","url":"http:\/\/www.pocklitz.de","email":"opocklitz#t-online.de","address":{"#type":"PostalAddress","postalCode":"65931","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Erfurter Weg 21"},"telephone":"(069) 765820","aggregateRating":{"#type":"AggregateRating","worstRating":1,"bestRating":5,"ratingValue":1,"reviewCount":3,"itemReviewed":{"#type":"Organization","name":"Dachdecker Olaf Pocklitz"}}}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Dachdeckerei Havan","url":"http:\/\/www.dachdeckereihavan.de","email":"info#dachdeckereihavan.de","address":{"#type":"PostalAddress","postalCode":"60599","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Offenbacher Landstr. 364"},"telephone":"(069) 651540"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Dachdeckerfachbetrieb Thomas Piller","email":"piller-bedachungen#gmx.de","address":{"#type":"PostalAddress","postalCode":"60439","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Eduard-Bernstein-Weg 3"},"aggregateRating":{"#type":"AggregateRating","worstRating":1,"bestRating":5,"ratingValue":5,"reviewCount":1,"itemReviewed":{"#type":"Organization","name":"Dachdeckerfachbetrieb Thomas Piller"}}}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Dachdeckermeisterbetrieb Tuvana","url":"http:\/\/www.tuvana-dach.de","email":"info#tuvana-dach.de","address":{"#type":"PostalAddress","postalCode":"60596","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Tiroler Str. 28c"},"telephone":"(069) 78809681"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Decos GmbH","url":"http:\/\/www.decos-gmbh.de","email":"decosgmbh#web.de","address":{"#type":"PostalAddress","postalCode":"60388","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Flinschstr. 21"},"telephone":"(069) 42603940"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Dejan Miloradovic","email":"dmilo#web.de","address":{"#type":"PostalAddress","postalCode":"60487","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Sophienstr. 25"},"telephone":"(069) 703177"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Denstedt Bedachungs-GmbH","email":"denstedt.bedachungsgmbh#t-online.de","address":{"#type":"PostalAddress","postalCode":"60388","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Riedstr. 43"},"telephone":"(06109) 31967"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Der Zollstock - Ulrich Heuser & Hans-J\u00fcrgen Kurth","url":"https:\/\/www.der-zollstock.de","email":"kundenbetreuung#der-zollstock.de","address":{"#type":"PostalAddress","postalCode":"60388","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"R\u00f6ntgenstr. 8"},"telephone":"(06109) 378400"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Die Stadtzimmerei Stefan Scherer","url":"http:\/\/www.die-stadtzimmerei.de","email":"info#die-stadtzimmerei.de","address":{"#type":"PostalAddress","postalCode":"60385","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Wittelsbacherallee 102"},"telephone":"(069) 43059517"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"einfeldt Baudekoration GmbH","url":"https:\/\/www.einfeldt-baudeko.de","email":"info#einfeldt-baudeko.de","address":{"#type":"PostalAddress","postalCode":"60386","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Orber Str. 42"},"telephone":"(06039) 3878"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Emil Scholz GmbH & Co. KG","url":"https:\/\/www.malerteam-scholz.de","email":"info#malerteam-scholz.de","address":{"#type":"PostalAddress","postalCode":"60385","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Ostparkstr. 55"},"telephone":"(069) 943411-0","aggregateRating":{"#type":"AggregateRating","worstRating":1,"bestRating":5,"ratingValue":1,"reviewCount":1,"itemReviewed":{"#type":"Organization","name":"Emil Scholz GmbH & Co. KG"}}}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Ewald Thamer","email":"ewald.thamer#t-online.de","address":{"#type":"PostalAddress","postalCode":"65931","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Hesselbergweg 30"},"telephone":"(069) 36402623"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"Falke Designs","email":"info#falke-designs.de","address":{"#type":"PostalAddress","postalCode":"60486","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Kaufunger Str. 16"},"telephone":"(0173) 8605872"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"FarbHey GmbH & Co.KG Malerfachbetrieb","url":"https:\/\/www.farbhey.de","email":"kontakt#farbhey.de","address":{"#type":"PostalAddress","postalCode":"60433","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Am Gr\u00fcnen Graben 20"},"telephone":"(069) 516309"}},{"#type":"ListItem","item":{"#type":"LocalBusiness","name":"FBM Boras Facility & Bau Management GmbH","url":"https:\/\/www.fbmgmbh.de","email":"info#fbmgmbh.de","address":{"#type":"PostalAddress","postalCode":"60594","addressLocality":"Frankfurt","addressRegion":"Hessen","streetAddress":"Darmst\u00e4dter Landstr. 4"},"telephone":"(069) 63159155"}}],"name":"Alle Ergebnisse f\u00fcr Handwerker in Frankfurt online vergleichen"}}
console.log( d.mainEntity.itemListElement[0].item.email)

Error $ProfilePictureUrl is not replacing the pic id from My Database i.e Firebase realtime database

I 'm developing Google Assistant in #js , I when user clicks my link http://host/$Profile , it needs to show profile pic but, $profile is in my database, the $profile should be replaced like 423466934206595086.jpg which is in my database. This is my code
"buttonUrl: 'http://armws.sste.saiveeetha.com/Content/ProfilePicture/$ProfilePictureUrl' "----->when i click on that the url i.e $ProfilePictureUrl is not replacing the Pic Id................I don't know how to do that.........Please help me ....!!!
const EmpId = agent.parameters.EmpId;
var ref3 = admin.database().ref().child("Table/");
var query3 = ref3.orderByChild("EmpId").equalTo(EmpId);
return query3.once("value",function(snapshot) {
snapshot.forEach(function(child) {
agent.add(`The Faculty name is ` + child.val().FirstName);
agent.add(new Card({
title: ` Name:${child.val().FirstName}
Employee Id: ${child.val().EmpId}
Address:: ${child.val().Address}
Email : ${child.val().EmailId}
DOB : ${child.val().DateOfBirth}
Department: ${child.val().DepartmentName}`,
imageUrl: 'https://eencrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR7lF8oXwLpXitlwizIdXVM-cGRTGqi79X3I4t5oBlNfhGe8mKN3Dg',
text: `Thanks for using Saveetha Google Assistant 💁\n DR ${child.val().FirstName} 💁`,
buttonText: 'View Profile Picture',
buttonUrl: 'http://........./Content/ProfilePicture/$ProfilePictureUrl'
You are using JavaScript template literals! the wrong way.
in order for this buttonUrl: 'http://........./Content/ProfilePicture/$ProfilePictureUrl' to be parsed by js you need to rewrite it as
buttonUrl: `http://........./Content/ProfilePicture/${ProfilePictureUrl}`
this way JS will replace your variable ProfilePictureUrl with its value.
JS template literals must start with a backtick
var ProfilePictureUrl = 'World';
console.log(`Hello ${ProfilePictureUrl}`);
this will print out Hello World to the console

Return Youtube video URL from keyword search with Javascript

Alright , so I'm making a bot in Discord for my server, and something I wanted to implement is a youtube command.
I've been searching all over and looking in the Youtube API and all I can find is their search for what seems like a browser
I'm using nodejs to run it off of my laptop, and my bot runs off of discord.jsI have a similar command that does a MAL and a Urban Dictionary search, but I've found nothing and have no idea how to do the same with youtube
I used to have a command for a python bot that was able to due this, and I've seen other Discord bots able to do it as well, so I know it's obviously possible
Basically what I'm saying is I need to be able to search for and return a youtube video URL (the first search result) from a string of search terms so the usage would look like
>>youtube Tunak Tunak Tun
Would return
https://www.youtube.com/watch?v=vTIIMJ9tUc8 , which is the first search result for that keyword(s)
EDIT:I've found the python command that would do this, but have nigh the skills nor the confidence to try to translate this to JavaScript
elif prefix and cmd=="youtube" and len(args) > 0:
try:
yword=args.replace(" ","_")
ydata= urlreq.urlopen("http://gdata.youtube.com/feeds/api/videos?vq="+yword+"&racy=include&orderby=relevance&max-results=1")
yread= str(ydata.read())
if "<openSearch:totalResults>0</openSearch:totalResults>" in yread:
room.message("I got nothin' for ya by the name of "+args)
else:
trash , yclean=yread.split("<media:player url='http://www.youtube.com/watch?v=",1)
yclean , trash=yclean.split("&",1)
room.message("http://http://www.youtube.com/watch?v="+yclean,True)
except:
room.message("Somethin ain't right")
EDIT2 (Apologies for length) : Alright! I've found something that's gotten me a lot closer!
https://www.npmjs.com/package/youtube-search
I've got a command in my bot now that goes something like this:
if (commandIs("yt" , message)){
search(args.join(' ').substring(4), opts, function(err, results) {
if(err) return console.log(err);
message.channel.sendMessage(results);
console.log(results);
});
}
So now when I enter >>yt Tunak Tunak Tun I get
[ { id: 'vTIIMJ9tUc8',
link: 'https://www.youtube.com/watch?v=vTIIMJ9tUc8',
kind: 'youtube#video',
publishedAt: '2014-03-21T07:00:01.000Z',
channelId: 'UC3MLnJtqc_phABBriLRhtgQ',
channelTitle: 'SonyMusicIndiaVEVO',
title: 'Daler Mehndi - Tunak Tunak Tun Video',
description: 'Presenting \'Tunak Tunak Tun\' music video sung by the talented Daler Mehndi Song Name - Tunak Tunak Tun Album - Tunak Tunak Tun Singer - Daler Mehndi ...',
thumbnails: { default: [Object], medium: [Object], high: [Object] } } ]
in the console and [object Object] in the discord channel.
http://i.imgur.com/Vorpn0f.png
So the problem now is I have the link in my reach, but I can not get it to return JUST the link, and I've no idea how to pull it out of that mess.
It sounds like your results object is a JSON string. This essentially means that it is a string representation of a javascript object. You can parse this into an object by using JSON.parse().
var objResults = JSON.parse(results);
console.log(objResults);
console.log(objResults.link);
EDIT
Failed to notice that your result is actually an array. You just need to access it like this: console.log(results[0].link). Shouldn't need to JSON.parse()
Okay, here's another approach that is working for me, using the google javascript API. Once again, the SO snippet doesn't run it, so I'll link you to the fiddle.
This method requires you to setup a google API key, then enable youtube API access.
I've removed my google API key from the fiddle, so you'll need to set that up. I can PM you mine if you want to test first though.
var apiKey = null //put your API key here
function search() {
var searchTerm = $('#txtSearch').val()
gapi.client.init({
'apiKey': apiKey,
'discoveryDocs': ['https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest']
}).then(function() {
return gapi.client.youtube.search.list({
q: searchTerm,
part: 'snippet'
});
}).then(function(response) {
var searchResult = response.result;
$('#search-results').append(JSON.stringify(searchResult, null, 4))
console.log(searchResult.items[0])
var firstVideo = searchResult.items[0]
firstVideo.url = `https://youtube.com/watch?v=${firstVideo.id.videoId}`
$('#first-video').text(firstVideo.url).attr('href', firstVideo.url)
$('#first-video-title').text(firstVideo.snippet.title)
$('#first-video-description').text(firstVideo.snippet.description)
});
}
$('#btnSearch').on('click', function() {
$('#first-video-title').text("")
if (!apiKey) {
$('#first-video-title').text("You need to set an apiKey!")
return;
}
gapi.load('client', search)
});
#search-results { white-space: pre; font-family: monospace; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src='https://apis.google.com/js/api.js'></script>
<div id="container">
<input id="txtSearch" type="text" />
<button id="btnSearch">
Search!
</button>
<br />
<p id='first-video-title'> </p>
<p id='first-video-description'></p>
<a target="_blank" id="first-video"></a>
<div id='search-results'>
</div>
</div>

Change content of a div based on an array within an array

Pastebin of index.html: http://pastebin.com/kdKFqTxe
Just copy and paste that and run it (this works but with some broken img links & no css).
With regards to the pastebin, just click on a node, and then click the first broken image below the video. What should happen is a dialogue box should appear with links to articles (from tubeArray). All relevant code is pasted below.
I'm trying to dynamically change the contents of a div when I click an image. The image has it's respective id (the first index in the inner array) within the first inner array there's another array (index 3). I want to populate my div (id="articleLinks") with those links using JQuery when the image is clicked.
JavaScript & JQuery:
The tube array. *Note: the first index of each element in tubeArray is the ID & the news articles aren't linked to anything particular. Only interested in tubeArray[0] & tubeArray[4]
var tubeArray = [
['UQ', -27.495134, 153.013502, "http://www.youtube.com/embed/uZ2SWWDt8Wg",
[
["example.com", "Brisbane students protest university fee hikes"],
["example.com", "Angry protests over UQ student union election"],
]
],
['New York', 40.715520, -74.002036, "http://www.youtube.com/embed/JG0wmXyi-Mw",
[
["example.com" , "NY taxpayers’ risky Wall Street bet: Why the comptroller race matters"]
]
],
['To The Skies', 47.09399, 15.40548, "http://www.youtube.com/embed/tfEjTgUmeWw",
[
["example.com","Battle for Kobane intensifies as Islamic State uses car bombs, Syrian fighters execute captives"],
["example.com","Jihadists take heavy losses in battle for Syria's Kobane"]
]
],
['Fallujah', 33.101509, 44.047308, "http://www.youtube.com/embed/V2EOMzZsTrE",
[
["example.com","Video captures family cat saving California boy from dog attack"],
["example.com","Fines of £20,000 for dogs that chase the postman"]
]
]
];
A for loop which goes through each element in tubeArray then assigns id to the first index. Also an image that calls the function myFunctionId which takes the parameter this.id.
for (i = 0; i < tubeArray.length; i++) {
var id = tubeArray[i][0];
//other code
'<img src="img.png" onclick="myFunctionId(this.id);" id="' + id + '">' +
//other code
}
function myFunctionId (id) {
journal = id;
alert(journal) //just a test
//I want to search through tubeArray with the id and find the matching inner array.
//I then want to loop through the innerArray and append to my html a link using JQuery.
$('#articleLinks').append("<a href='"+innerArray[0]+"'>"+innerArray[1]+'</a>'); // use CSS to break lines
}
}
HTML:
<div id="articleLinks">
Example Link<br>
</div>
Any help would be greatly appreciated. I've tried to simplify & cut out as much as I can so it's readable.
try this...
function myFunctionId (id) {
console.log(tubeArray);
tubeArray.forEach(function(entry) {
if (entry[0]==id) {
entry[4].forEach(function(innerArray){
$('#articleLinks').append("<a href='"+innerArray[0]+"'>"+innerArray[1]+'</a>'); // use CSS to break lines
});
return;
}
});
}
it makes it look like this for me... you're gonna have to handle that encoding issue. with the apostrophe. there are a lot of ways to handle it...
so.... if it was me... which it's not. but if it was... i would use an associative array instead of a numerically indexed one because it's easier to read the code and understand what you're using and where and how and things and stuff.
tubeArray = {
'UQ' : { 'location': [-27.495134, 153.013502],
'youtube': "example.com/embed/uZ2SWWDt8Wg",
'articles': [["example.com/queensland/brisbane-students-protest-university-fee-hikes-20140521-zrk8o.html", "Brisbane students protest university fee hikes"],
["example.com/content/2012/s3578878.htm", "Angry protests over UQ student union election"], ]
},
'New York': { 'location': [0.715520, -74.002036],
'youtube': "example.com/embed/JG0wmXyi-Mw",
'articles': [["example.com/2014/10/19/ny-taxpayers-risky-wall-street-bet-why-the-comptroller-race-matters/" , "NY taxpayers’ risky Wall Street bet: Why the comptroller race matters"]],
},
}

Trouble parsing complex JSON response using JQuery (or just javascript)

Given the following function to grab JSON data from a Solr instance:
var url = "http://myserver:8080/solr/select?indent=on&version=2.2&q=(title:*Hollis* OR sub_title:*Hollis*+OR+creator:*Hollis*+OR+publisher:*Hollis*+OR+format:*Hollis*++OR+lcsh:*Hollis*++OR+loc_call_num_subject:*Hollis*+OR+note:*Hollis*++OR+toc:*Hollis*)AND+Match_Confidence:[.75+TO+*]&start=0&rows=3500&fl=Geocoded_Field,title,id_inst,Match_Confidence,Conjunct_Longitude1,Conjunct_Latitude1,Anchor,note,creator,format,language,pub_location,publisher,score&wt=json&group=true&group.field=title";
$.getJSON(url, function(data){
console.log("EXAMPLE TYPE:"+data.grouped.title.groups.docs[0].title);
});
How do I cycle through each response 'doc' (data posted below) and grab each "title" occurrence for example? I've tried numerous variations of data.grouped.title.groups.docs[0].title with no luck. I am thinking I just have the incorrect order in the data access string (data.grouped.title.groups.docs.title).
Sample data returned from query as copied and pasted from a browser:
{ "responseHeader":{
"status":0,
"QTime":902,
"params":{
"indent":"on",
"wt":"json",
"version":"2.2",
"rows":"3500", "fl":"Geocoded_Field,title,id_inst,Match_Confidence,Conjunct_Longitude1,Conjunct_Latitude1,Anchor,note,creator,format,language,pub_location,publisher,score",
"start":"0",
"q":"(title:*Hollis* OR sub_title:*Hollis* OR creator:*Hollis* OR publisher:*Hollis* OR format:*Hollis* OR lcsh:*Hollis* OR loc_call_num_subject:*Hollis* OR note:*Hollis* OR toc:*Hollis*)AND Match_Confidence:[.75 TO *]",
"group.field":"title",
"group":"true"}}, "grouped":{
"title":{
"matches":2533,
"groups":[{
"groupValue":"Thomas Hollis [and] Thomas Brand Hollis",
"doclist":{"numFound":3,"start":0,"maxScore":0.75592893,"docs":[
{
"title":"Thomas Hollis [and] Thomas Brand Hollis",
"Match_Confidence":0.894584,
"Conjunct_Latitude1":41.89,
"Conjunct_Longitude1":12.5,
"Geocoded_Field":[
"note"],
"pub_location":[
"1752"],
"Anchor":[
"Roma"],
"id_inst":[
"009360446"],
"language":["English"],
"format":["Other"],
"note":[
"Two bust portraits carved in bas-relief. One is of Thomas Hollis, the elder (1659-1731), and one of his friend and heir, Thomas Brand Hollis (ca.1719-1804). Portraits are framed together",
"Inscribed on front of each sculpture: Andrea Pozzi fece dal naturale; verso of Thomas Hollis inscribed: Ritratto del Sig: re Tommaso / Hollis, Cau: re Inglese, Termina= / to in Roma nel suo Giorno Nat= / alizio de i 14 Aprile 1752 in / Et di 32 Ani; verso of Thomas Brand Hollis inscribed: Ritratto dell'Illust: o Sig: re / Tommaso Brand, Caualiere / Inglese, Fatto in Roma / Nell' Anno 1752",
"Title taken from plaques",
"Framed and glazed"],
"creator":["Pozzi, Andrea, 1718-1769","Hollis, Thomas, 1720-1774, former owner"],
"score":0.75592893}]
}},
{
"groupValue":"The post of duty",
"doclist":{"numFound":24,"start":0,"maxScore":0.5459487,"docs":[
{
"title":"The post of duty",
"Match_Confidence":0.985783,
"Conjunct_Latitude1":42.4842,
"Conjunct_Longitude1":-76.4799,
"Geocoded_Field":[
"lcsh"],
"pub_location":[
"Coxsackie, N. Y"],
"Anchor":[
"Lansing"],
"id_inst":[
"006317718"],
"language":["English"],
"format":["Book"],
"note":[
"Published by request"],
"publisher":[
"F.C. Dedrick, Printer"],
"creator":["Zabriskie, Francis Nicoll, 1832-1891"],
"score":0.5459487}]
}},
{
"groupValue":"Discourses concerning government: in way of dialogue",
"doclist":{"numFound":1,"start":0,"maxScore":0.41996053,"docs":[
{
"title":"Discourses concerning government: in way of dialogue",
"Match_Confidence":0.95121,
"Conjunct_Latitude1":51.5142,
"Conjunct_Longitude1":-0.093145,
"Geocoded_Field":[
"pub_location"],
"pub_location":[
"London"],
"Anchor":[
"London"],
"id_inst":[
"006199101"],
"language":["English"],
"format":["Book"],
"note":[
"First published 1681 under title: Plato redivivus",
"Bound in old mottled calf, rebacked"],
"publisher":[
"Printed, and sold by A. Baldwin"],
"creator":["Neville, Henry, 1620-1694","Hollis, Thomas, 1720-1774, former owner"],
"score":0.41996053}]
}}]}}}
See this jsfiddle http://jsfiddle.net/ByxHV/
for (var i =0; i < data.grouped.title.groups.length; i++) {
var group = data.grouped.title.groups[i];
console.log(group.groupValue, group.doclist.numFound)
}​
I used JSON Pretty Print to examine the JSON
var titleList = [];
$.each(data.grouped.title.groups, function(index, value) {
$.each(value.doclist.docs, function(index, value) {
titleList.push(value.title);
});
});

Categories

Resources