Re: getting html source code from website

188 views
Skip to first unread message

Kevin Gillette

unread,
Oct 29, 2012, 11:27:53 AM10/29/12
to golan...@googlegroups.com
Check the errors from http.Get and ioutil.ReadAll. Chances are, there's some issue on windows which is being reported, but which you're explicitly ignoring. By the way, any time you show code using blanked errors anywhere within the Go community, you'll invariably be advised to not ignore them, even if it has nothing to do with the problem (though in this case, I believe it does).

Dumitru Ungureanu

unread,
Oct 29, 2012, 1:49:24 PM10/29/12
to golan...@googlegroups.com
It's working on my Win.

If I had to guess, I'd say it has something to do with the online security on your Win machine. Are you able to open http://www.yahoo.com/ in a browser on that machine?

Joshua

unread,
Oct 29, 2012, 3:24:14 PM10/29/12
to golan...@googlegroups.com
I notice that when I try to run the code on my Windows box behind a proxy, it fails (with no errors).

Joshua

On Monday, October 29, 2012 8:42:02 AM UTC-4, Aldis Andrejevs wrote:
Hi all, I have one question:

====================================
package main

import (
"fmt"
"net/http"
"io/ioutil"
)

func main() {
res, _ := http.Get("http://www.yahoo.com/")
html, _ := ioutil.ReadAll(res.Body)
res.Body.Close()
fmt.Printf("%s", html)
}
=========================================

this is program which I compile under LinuxOS and under WindowsOS code is the same for both operating systems

but on WindowsOS I don't receive source code however under LinuxOS all works as expected

maybe someone knows solution for this ?

thanks..

Miki Tebeka

unread,
Oct 29, 2012, 7:17:25 PM10/29/12
to golan...@googlegroups.com
What are the HTTP headers returned?
Reply all
Reply to author
Forward
0 new messages