diff options
author | Jordan <me@jordan.im> | 2022-03-27 14:23:37 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2022-03-27 14:23:37 -0700 |
commit | d6475f61341713042004cd5569060c728bf2080f (patch) | |
tree | 381762de4f23b0399c32160dd780cbf643862064 | |
parent | 53323a42e1037dfb6c55ae396c53996ea5606ed9 (diff) | |
download | crane-d6475f61341713042004cd5569060c728bf2080f.tar.gz crane-d6475f61341713042004cd5569060c728bf2080f.zip |
util:go: HTML parsing patch; generalize article location
-rw-r--r-- | util.go | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -269,20 +269,17 @@ func getPaper(client *http.Client, u string) (string, error) { var dl *url.URL var f func(*html.Node) f = func(n *html.Node) { - if n.Type == html.ElementNode && n.Data == "embed" { + if n.Type == html.ElementNode { for _, a := range n.Attr { if a.Key == "src" { - _u, err := url.Parse(u) - if err != nil { - continue - } _v, err := url.Parse(a.Val) if err != nil { continue } + fmt.Println(_v.Path) if strings.HasSuffix(_v.Path, "pdf") { - _u.Path = _v.Path - dl = _u + dl = _v + break } } } |