Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func getThairath(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
- urlReq := "https://www.thairath.co.th/home"
- req, err := http.NewRequest("GET", urlReq, nil)
- if err != nil{
- w.Write([]byte(err.Error()))
- }
- req.Header.Add("authority", "www.thairath.co.th")
- req.Header.Add("pragma", "no-cache")
- req.Header.Add("cache-control", "no-cache,no-cache")
- req.Header.Add("upgrade-insecure-requests", "1")
- req.Header.Add("user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36")
- req.Header.Add("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
- req.Header.Add("accept-language", "en-US,en;q=0.9")
- res, err := http.DefaultClient.Do(req)
- if err != nil{
- w.Write([]byte(err.Error()))
- }
- defer res.Body.Close()
- body, err := ioutil.ReadAll(res.Body)
- if err != nil{
- w.Write([]byte(err.Error()))
- }
- w.Write(body)
- }
Advertisement