4

Is it possible to use gdata javascript or any other javascript api to retrieve the list of blog posts based on labels?

My usage case:

Each blog post has a label that means its category. Some posts are labelled with 'Summary' and the category it belongs.

I want to be able to display the summary of MyCategory(Label) on the label's page. e.g. http://myblog.blogspot.com/search/label/MyCategory

Is it possible to retrieve the list of blog posts matching 'Summary' and 'MyCategory'?

UPDATE:

more details:

  • it is a blog I have edit access to
  • the js can be placed on google sites or inside the blog html
  • the blog has 18k+ posts, so listing all posts and filtering is not an option.
  • myblog.blogspot was referring to any blogger, not the actual one. I was just talking about label-based blogger filter.
Johnny Everson
  • 8,343
  • 7
  • 39
  • 75

1 Answers1

1

I've read and re-read this question and blogspot-link a couple of times. It's difficult to understand.

I think it would help if you gave some more information:

  • where do you want to place this javascript? I mean: is it going to be placed on the same blog? I'm asking because this determines cross-site security requirements.
  • I have a strong feeling this is actually a question where you want to a cross-domain request (load data from a different domain|server (blogspot.com)) that you do not control, otherwise you'd be playing with 'Access-Control-Allow-Origin' on the server-side.
  • Will this script be located in a online or local (x)html source?
  • Could you please provide a more elaborate example (or sample) of an existing list that contain's this labels, or do you want to crawl a blog like a spider|index-robot?

If the above assumptions are correct, the first part of your problem is retrieving cross-domain data (which is hard nowadays using simple solutions like XMLHttpRequest aka AJAX).
You could then start looking at some own server-side scripts (php) to get this data and send it (pre-parsed) to your browser-application (effectively this is simply a proxy located on your own domain).
I have also heard of using a java-object (or silverlight? or flash which nowadays also suffers from cross-domain-security restrictions), to get around this modern day cross-domain security.
You could then embed one or more of these objects (that retrieve the source) and communicate with them through javascript. A variation of this technique is also often used for cross-browser multiple file-uploads.
There is a big chance there is already a solution (object) to this part of your problem here on StackOverflow.

If you fix this first part of the problem, the second part of your problem simply comes down to parsing (regex for example) your retrieved 'label'-data, building new links from them to retrieve the 'summary'-content you where after, using the same data-retrieval technique that was used to get the labels-list in the first place..

Is this what you are after?

UPDATE: In pure javascript/json there is an excellent topic here on SO.
Should you go with java, you could look at this.
In php you use file_get_contents() or file_get_html(). See also this topic on SO.

UPDATE2: The accepted ANSWER (out of comment's below:)
On google's developers blogger docs 2.0 you can find: RetrievingWithQuery.
Quote:

/category
   Specifies categories (also known as labels) to filter the feed results. For example, blogger.com/feeds/blogID/posts/default/-/Fritz/Laurie returns entries with both the labels Fritz and Laurie.

You can also find a working piece of javascript that uses this technique over here: list-recent-posts-by-label

Now you can simply continue 'AJAX'ing your summary's out of this filtered list.

Good luck!

Community
  • 1
  • 1
GitaarLAB
  • 14,536
  • 11
  • 60
  • 80
  • Hi. Thanks but that is not whst I am after. Please see updates. – Johnny Everson Jul 24 '12 at 18:47
  • My problem here is not how to read the page. Is more like: what query should/feed/url should I access to get that info. – Johnny Everson Jul 24 '12 at 19:18
  • after reading your update: Logically you don't want to crawl 18k+ posts. And I'm guessing you do not have access to the database that contains the labels and content? Otherwise it would be a simple sql statement.. You might want to ask blogspot.com if they could implement such a simple search-page.. (if they haven't already) then you'd be good to go together with AJAX like techniques (mentioned in my awnser's update), since the cross-domain security part is no issue as long as the javascript (that can be hosted elsewhere) is run on a page on the same domain. – GitaarLAB Jul 24 '12 at 19:23
  • Isn't this a duplicate of your [own post](http://stackoverflow.com/questions/11057732/retrieve-list-of-all-labels-in-blogger) here on SO? Anyway you want to 'retrieve the list of blog posts based on labels' then this seems to do in javascript what you want: [list-recent-posts-by-label](http://www.bloggersentral.com/2010/04/list-recent-posts-by-label.html). Now you can simply continue 'AJAX'ing your summary's out of this filtered list. – GitaarLAB Jul 24 '12 at 19:48
  • No, in blogger you don't have direct access to the database. This is not a duplicate. There I wanted to find the labels. Now I want to find labeled posts. – Johnny Everson Jul 24 '12 at 20:05
  • did you read [RetrievingWithQuery](https://developers.google.com/blogger/docs/2.0/developers_guide_protocol#RetrievingWithQuery) on google's developers blogger docs 2.0? Quote: /category Specifies categories (also known as labels) to filter the feed results. For example, http://www.blogger.com/feeds/blogID/posts/default/-/Fritz/Laurie returns entries with both the labels Fritz and Laurie. Just as the link in my previous comment (I believe). – GitaarLAB Jul 24 '12 at 20:11
  • That is exactly what I want :). Please put in the answer so I can accept it. Thanks. I over looked that. – Johnny Everson Jul 24 '12 at 20:14
  • I'll do that now, thx for the points :) (this one took quite some time). – GitaarLAB Jul 24 '12 at 20:17