From ed2bc742ee9eae3812d263277d19fd61b9cb22d5 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 22 Dec 2020 13:04:04 -0500 Subject: [PATCH] fix hoot to work with twitter's crap --- docs/changelog.txt | 4 ++++ hoot.go | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 0367592..5d8894f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,5 +1,9 @@ changelog +=== next + ++ Fix hoot to work with Twitter's latest crap. + === 0.9.5 Emergency Ejection + Fix honk init user creation. diff --git a/hoot.go b/hoot.go index 3adb72b..4bac1e1 100644 --- a/hoot.go +++ b/hoot.go @@ -29,8 +29,8 @@ import ( "humungus.tedunangst.com/r/webs/htfilter" ) -var tweetsel = cascadia.MustCompile("div.tweet-text") -var linksel = cascadia.MustCompile("td.timestamp a") +var tweetsel = cascadia.MustCompile("p.tweet-text") +var linksel = cascadia.MustCompile("a.tweet-timestamp") var replyingto = cascadia.MustCompile(".ReplyingToContextBelowAuthor") var authorregex = regexp.MustCompile("twitter.com/([^/]+)") @@ -109,14 +109,13 @@ func hooterize(noise string) string { url = url[1:] } url = strings.Replace(url, "mobile.twitter.com", "twitter.com", -1) - url = strings.Replace(url, "twitter.com", "mobile.twitter.com", -1) log.Printf("hooterizing %s", url) req, err := http.NewRequest("GET", url, nil) if err != nil { log.Printf("error: %s", err) return hoot } - req.Header.Set("User-Agent", "OpenBSD ftp") + req.Header.Set("User-Agent", "Bot") req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") req.Header.Set("Accept-Language", "en-US,en;q=0.9") resp, err := http.DefaultClient.Do(req)