mIRC Home    About    Download    Register    News    Help

Print Thread
#242821 05/09/13 12:31 PM
Joined: Sep 2013
Posts: 2
H
hyjakx Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
H
Joined: Sep 2013
Posts: 2
hi guys and girl im new to scripting having trouble trying to get my script to work. blogspot has its browser feeds usually in like somesite.blogspot.com/feeds/posts/default

I want to open a socket, grab the latest post that being <title> and <description> and echo it.

(dont laugh please i tried many things its probably way of)

on *:SOCKREAD:latest: {
sockread %latest

if $regex(%latest,/<title> </title>([^<>]+)/) {
var %title $regml(1)
}

if $regex(%latest,/<description> <description>([^<>]+)/) {
var %description $regml(1)
}
echo -a %title %description
}

even if that worked that would get all with <title> and <description> i only want the latest then echo it.

hyjakx #242824 05/09/13 03:12 PM
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
I checked out the XML you're receiving, but I don't see any description node and the title is not as you provided, so I don't know if I'm looking at the right page. This is what I checked: http://code.blogger.com/feeds/posts/default

That's pretty monstrous, I'd suggest using the blogger api instead. You'll need to request an api key and the responses will be in json instead of xml. There's an existing json script for mirc which supports url caching and parsing so you'll need to do very little else if you decide to use it.

Here is the json script:
http://www.mircscripts.org/comments.php?cid=4407

Without an api key you will be given an error for most (if not all) requests, if you provide an invalid key (as I have done here) you'll receive a "Bad Request" error. Until you get your key you can use the api reference page (below), this will give you valid responses to work with which you can save to file for testing.

Here is a functioning example that will display either the error message or (once you've supplied the api key) the title of the post:

Code:
alias blogger {
  var %url = https://www.googleapis.com/blogger/v3/blogs/3213900/posts?fetchBodies=false&maxResults=1&key=YOUR_API_KEY
  ;var %url = json.txt
  var %error.code = $json(%url,error,code)
  if (%error.code) {
    echo -ag $json(%url,error,message)
  }
  else {
    echo -ag $json(%url,items,0,title)
  }
}


This is to get you started with the blogger api:
https://developers.google.com/blogger/docs/3.0/getting_started

To retrieve a blog's id you can use this page:
https://developers.google.com/blogger/docs/3.0/reference/blogs/getByUrl#try-it

This is the specific method reference I used:
https://developers.google.com/blogger/docs/3.0/reference/posts/list

This last link is very useful, it allows you to try out the method and will supply you with the request to make and the response that's given. You can even request that only some of the fields be retrieved (the page has a useful section where you check off what you want) - this is recommended for performance.

Request:
Code:
https://www.googleapis.com/blogger/v3/blogs/3213900/posts?fetchBodies=false&maxResults=1&key={YOUR_API_KEY}


Response:
Code:
{
 "kind": "blogger#postList",
 "nextPageToken": "CgkIARigkLqN3ycQzJTEAQ",
 "items": [
  {

   "kind": "blogger#post",
   "id": "8266404449195608384",
   "blog": {
    "id": "3213900"
   },
   "published": "2013-04-09T19:03:00-07:00",
   "updated": "2013-04-18T12:18:46-07:00",
   "url": "http://code.blogger.com/2013/04/improvements-to-blogger-template-html.html",
   "selfLink": "https://content.googleapis.com/blogger/v3/blogs/3213900/posts/8266404449195608384",
   "title": "Improvements to the Blogger template HTML editor",
   "author": {
    "id": "g112374322230920073195",
    "displayName": "Emily Wood",
    "url": "http://www.blogger.com/profile/08434147677241700960",
    "image": {
     "url": "http://img2.blogblog.com/img/b16-rounded.gif"
    }
   },
   "replies": {
    "totalItems": "0",
    "selfLink": "https://content.googleapis.com/blogger/v3/blogs/3213900/posts/8266404449195608384/comments"
   }
  }
 ]
}

Joined: Sep 2013
Posts: 2
H
hyjakx Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
H
Joined: Sep 2013
Posts: 2
thank you but not what i needed as blogspot shows up differently to that i will just keep trying to get it to work correctly.

hyjakx #242830 06/09/13 05:32 AM
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
This is exactly what you need, why don't you give me the url you're working with (or a similar one) so that I can show you?


Link Copied to Clipboard