files search added (wip)
This commit is contained in:
parent
585684f15b
commit
31460ee6be
13 changed files with 431 additions and 44 deletions
|
@ -1,4 +1,3 @@
|
|||
// forums.go
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -23,13 +22,13 @@ type ForumSearchResult struct {
|
|||
func PerformRedditSearch(query string, safe string, page int) ([]ForumSearchResult, error) {
|
||||
const (
|
||||
pageSize = 25
|
||||
baseURL = "https://www.reddit.com/"
|
||||
baseURL = "https://www.reddit.com"
|
||||
maxRetries = 5
|
||||
initialBackoff = 2 * time.Second
|
||||
)
|
||||
var results []ForumSearchResult
|
||||
|
||||
searchURL := fmt.Sprintf("%ssearch.json?q=%s&limit=%d&start=%d", baseURL, url.QueryEscape(query), pageSize, page*pageSize)
|
||||
searchURL := fmt.Sprintf("%s/search.json?q=%s&limit=%d&start=%d", baseURL, url.QueryEscape(query), pageSize, page*pageSize)
|
||||
var resp *http.Response
|
||||
var err error
|
||||
|
||||
|
@ -86,7 +85,7 @@ func PerformRedditSearch(query string, safe string, page int) ([]ForumSearchResu
|
|||
}
|
||||
publishedDate := time.Unix(int64(postData["created_utc"].(float64)), 0)
|
||||
permalink := postData["permalink"].(string)
|
||||
resultURL := baseURL + permalink
|
||||
resultURL := fmt.Sprintf("%s%s", baseURL, permalink)
|
||||
|
||||
result := ForumSearchResult{
|
||||
URL: resultURL,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue