getting html source code from website
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Aldis Andrejevs <andrej... @gmail.com>
Date: Mon, 29 Oct 2012 05:42:02 -0700 (PDT)
Local: Mon, Oct 29 2012 8:42 am
Subject: getting html source code from website
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..
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Kevin Gillette <extemporalgen... @gmail.com>
Date: Mon, 29 Oct 2012 08:27:53 -0700 (PDT)
Local: Mon, Oct 29 2012 11:27 am
Subject: Re: getting html source code from website
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).
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
gofans... @gmail.com
Date: Mon, 29 Oct 2012 10:04:58 -0700 (PDT)
Local: Mon, Oct 29 2012 1:04 pm
Subject: Re: getting html source code from website
i ran your code on my windows machine and got the expected html. so your code worked in my environment.
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..
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Dumitru Ungureanu <itmit... @gmail.com>
Date: Mon, 29 Oct 2012 10:49:24 -0700 (PDT)
Local: Mon, Oct 29 2012 1:49 pm
Subject: Re: getting html source code from website
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?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Joshua <jhaw... @gmail.com>
Date: Mon, 29 Oct 2012 12:24:14 -0700 (PDT)
Local: Mon, Oct 29 2012 3:24 pm
Subject: Re: getting html source code from website
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..
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Miki Tebeka <miki.teb... @gmail.com>
Date: Mon, 29 Oct 2012 16:17:25 -0700 (PDT)
Local: Mon, Oct 29 2012 7:17 pm
Subject: Re: getting html source code from website
What are the HTTP headers returned?
On Monday, October 29, 2012 12:24:14 PM UTC-7, Joshua wrote:
> 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..
You must
Sign in before you can post messages.
You do not have the permission required to post.