Help us understand the problem. What is going on with this article?

Goでニコニコ生放送のRSSから開場日時や放送開始日時を抽出してみる

More than 3 years have passed since last update.

GAE (Go/Python) もくもく勉強会 in 横浜タネマキ vol.12 で調べた結果のメモ。標準ライブラリだけで行けた。

parsenicoliverss.go
package main

import (
    "encoding/xml"
    "fmt"
    "io/ioutil"
    "net/http"
)

type Item struct {
    XMLName     xml.Name `xml:"item"`
    Title       string   `xml:"title"`
    Description string   `xml:"description"`
    OpenTime    string   `xml:"http://live.nicovideo.jp/ open_time"`
    StartTime   string   `xml:"http://live.nicovideo.jp/ start_time"`
}

type Channel struct {
    XMLName xml.Name `xml:"channel"`
    Title   string   `xml:"title"`
    Items   []Item   `xml:"item"`
}

type Rss struct {
    XMLName xml.Name `xml:"rss"`
    Channel Channel  `xml:"channel"`
}

func main() {
    res, err := http.Get("http://live.nicovideo.jp/rss")
    if err != nil {
        panic(err)
    }
    defer res.Body.Close()
    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
        panic(err)
    }

    r := Rss{}
    if err := xml.Unmarshal(body, &r); err != nil {
        panic(err)
    }
    fmt.Printf("RSSタイトル: %s\n", r.Channel.Title)
    fmt.Println("----------")
    for _, v := range r.Channel.Items {
        fmt.Printf("番組タイトル: %s\n", v.Title)
        fmt.Printf("番組説明文: %s\n", v.Description)
        fmt.Printf("開場日時: %s\n", v.OpenTime)
        fmt.Printf("放送開始日時: %s\n", v.StartTime)
        fmt.Println("----------")
    }
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away