亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

: URL 中的第一個路徑段不能包含冒號

: URL 中的第一個路徑段不能包含冒號

Go
翻閱古今 2023-06-01 18:21:36
這是我的代碼(其中的一部分):type SitemapIndex struct {    // Locations []Location `xml:"sitemap"`    Locations []string `xml:"sitemap>loc"`}~~~ SNIP ~~~func main(){    var s SitemapIndex    resp, _ := http.Get("https://www.washingtonpost.com/news-sitemaps/index.xml")    bytes, _ := ioutil.ReadAll(resp.Body)    xml.Unmarshal(bytes, &s)    for _, Location := range s.Locations {        fmt.Printf("%s\n", Location)        resp, err := http.Get(Location)        if err != nil {            log.Fatal(err)        } else {            bytes, _ := ioutil.ReadAll(resp.Body)            xml.Unmarshal(bytes, &n)            for idx := range n.Titles {                newsMap[n.Titles[idx]] = NewsMap{n.Keywords[idx], n.Locations[idx]}            }        }        for idx, data := range newsMap {            fmt.Println("\n\n\n", idx)            fmt.Println("\n", data.Keyword)            fmt.Println("\n", data.Location)        }    }現在,當我運行這段代碼時,我得到了這個輸出:https://www.washingtonpost.com/news-sitemaps/politics.xml2019/01/28 02:37:13 parse https://www.washingtonpost.com/news-sitemaps/politics.xml: first path segment in URL cannot contain colonexit status 1我讀了一些帖子并自己做了一些實驗,比如我用下面的代碼制作了另一個文件package mainimport ("fmt"    "net/url")func main(){    fmt.Println(url.Parse("https://www.washingtonpost.com/news-sitemaps/politics.xml"))}而且它沒有拋出任何錯誤,所以我知道錯誤與 url 無關?,F在,我幾個小時前才開始使用 senddex 的教程學習Go,所以現在還不太了解。這是視頻鏈接
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 286 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號