aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2022-03-27 14:23:37 -0700
committerJordan <me@jordan.im>2022-03-27 14:23:37 -0700
commitd6475f61341713042004cd5569060c728bf2080f (patch)
tree381762de4f23b0399c32160dd780cbf643862064
parent53323a42e1037dfb6c55ae396c53996ea5606ed9 (diff)
downloadcrane-d6475f61341713042004cd5569060c728bf2080f.tar.gz
crane-d6475f61341713042004cd5569060c728bf2080f.zip
util:go: HTML parsing patch; generalize article location
-rw-r--r--util.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/util.go b/util.go
index 0843cca..8fa9c5f 100644
--- a/util.go
+++ b/util.go
@@ -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
}
}
}