M
M
Michael2017-02-07 23:27:04
go
Michael, 2017-02-07 23:27:04

Why can't parse RSS?

Tried to write an RSS parser. At first I decided to take a ready-made module . But such code did not want to work in any way, nil was constantly returned:

package main

import "github.com/SlyMarbo/rss"

func main() {
    feed, err := rss.Fetch("https://habrahabr.ru/rss/hubs/all/")
    if err != nil {
        // handle error.
    }
}

I tried to write natively, but the same problem:
package main
import "net/http"
func main() {
    feed, err := http.Get("https://habrahabr.ru/rss/hubs/all/")
    if err != nil {
        fmt.Println(feed)
    } else {
        fmt.Println(err)
    }
    defer feed.Body.Close()
}

What could possibly be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
om1058, 2017-02-07
@mak_ufo

In your second example, swap the prints.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question