-
Notifications
You must be signed in to change notification settings - Fork 1
/
content.go
41 lines (32 loc) · 853 Bytes
/
content.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* content
Instagram Bot - autofollow, like, comment dan unfollow not followback (c) Free Angel - frxangelz@gmail.com
please subscribe to my channel :
https://www.youtube.com/channel/UC15iFd0nlfG_tEBrt6Qz1NQ
*/
package main
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
func getContent(url string, timeout_seconds int) ([]byte, error) {
timeout := time.Duration(time.Duration(timeout_seconds) * time.Second)
client := http.Client{
Timeout: timeout,
}
resp, err := client.Get(url)
//resp, err := http.Get(url)
if err != nil {
return nil, fmt.Errorf("GET error: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Status error: %v", resp.StatusCode)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Read body: %v", err)
}
return data, nil
}