[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to use access url using Ruby

sujeet kumar

6/2/2005 12:13:00 PM

hi
I am new to Ruby. I want to access http address using Ruby program .
I run the sample code of book The Pragmatic Programmer's Guide but it
doesn't work.
code is:
require 'net/http'

h = Net::HTTP.new('www.pragmaticprogrammer.com', 80)
resp, data = h.get('/index.html', nil )
puts "Code = #{resp.code}"
puts "Message = #{resp.message}"
resp.each {|key, val| printf "%-14s = %-40.40s\n", key, val }
p data[0..55]

Error is:
c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `initialize': getaddrinfo: no address
associated with hostname. (SocketError)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `new'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
from c:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
from c:/ruby/lib/ruby/1.8/net/http.rb:821:in `request'
from c:/ruby/lib/ruby/1.8/net/http.rb:615:in `get'
from url.rb:4

For information , I access internet through proxy server . Can anybody
tell me the error?
thanks

sujeet


9 Answers

Robert Klemme

6/2/2005 12:21:00 PM

0

sujeet kumar wrote:
> hi
> I am new to Ruby. I want to access http address using Ruby program .
> I run the sample code of book The Pragmatic Programmer's Guide but it
> doesn't work.
> code is:
> require 'net/http'
>
> h = Net::HTTP.new('www.pragmaticprogrammer.com', 80)
> resp, data = h.get('/index.html', nil )
> puts "Code = #{resp.code}"
> puts "Message = #{resp.message}"
> resp.each {|key, val| printf "%-14s = %-40.40s\n", key, val }
> p data[0..55]
>
> Error is:
> c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `initialize': getaddrinfo:
> no address associated with hostname. (SocketError)
> from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `new'
> from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `connect'
> from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
> from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
> from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `connect'
> from c:/ruby/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
> from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
> from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
> from c:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
> from c:/ruby/lib/ruby/1.8/net/http.rb:821:in `request'
> from c:/ruby/lib/ruby/1.8/net/http.rb:615:in `get'
> from url.rb:4
>
> For information , I access internet through proxy server . Can anybody
> tell me the error?
> thanks

See "Accessing via Proxy" on
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net...

Also preferrable use the block form to ensure proper closing of socket
connections.

Kind regards

robert

Neolibertarian

7/23/2011 6:48:00 PM

0

In article
<62305d0c-37de-4a69-a609-b0dbbcb3bb3b@a4g2000yqg.googlegroups.com>,
Raymond <Bluerhymer@aol.com> wrote:

> On Jul 23, 3:28?am, Neolibertarian <cognac...@gmail.com> wrote:
> > In article
> > <dc453b5c-d9dd-44b0-a3c6-7c6bea635...@z7g2000vbp.googlegroups.com>,
> >
> > ?Raymond <Bluerhy...@aol.com> wrote:
> > > The Grand Experiment Known As America Is Over..In American Politics
> > > the grand experiment has failed. Sadly, ?it is pretty much the end of
> > > America's grand colonial experiment
> >
> > You have to beware those premature autopsies.
> >
> >
> >
> > > Now we1re officially a Corporatocracy. The politicians have decided to
> > > end the grand American experiment in representative government
> >
> > "They" did no such thing.
> >
> > They did what you told them to do. What I told them to do. What We the
> > People told them to do.
> >
> > If this "experiment" fails, it won't be /their/ fault.
> >
> > --
> > Neolibertarian
> >
> > "Global Warming: It ain't the heat, it's the stupidity."
>
> Consider This
> How intelligent should ideal voters be?
>
> Voting may be meaningless at times.. In the Bush/Gore election
> millions of voters' vote meant nothing. In the end, one Supreme Court
> vote (5 to 4) put the worst candidate into the White House because he
> was the most likely to obey the real leaders of this nation... the oil
> company executives , the military industrial complex and the
> wealthiest 2 or 3 % of Americans

The Dubya won Florida. He'd already won Florida when the Gore got the
Florida Supreme Court involved. In the end, the Dubya won Florida no
matter which way you counted the votes.

What the US Supreme Court vote did was put an end to the Gore's
floundering attempts to change those results. For instance, the Gore
wanted to only recount the votes in districts /he'd already won/. Does
that make any sense to you at all?

But we know now that even had the USSC not gotten involved, the election
results would not have been overturned, anyway.

Your example is not well taken.
>
> Should Everyone be Allowed to Vote?
> Mar 18th, 2011
> The 74th smartest person in the world voices his views about whether
> EVERYONE should be allowed to vote!
>
> Should some people in society (other than those in jail or otherwise
> restricted) be restricted from voting? This is a topic I?ve thought
> about before. It was brought to my attention again by a reader in the
> comment section of this thread:

Computerize all voting booths.

When you walk into the booth, there's a randomly generated quadratic
equation on the screen.

Solve the equation, and the ballot appears.

--
Neolibertarian

"Global Warming: It ain't the heat, it's the stupidity."

Neolibertarian

7/23/2011 6:55:00 PM

0

In article
<c9e2c20c-b56d-4847-bf04-9c7269f679b5@h7g2000prf.googlegroups.com>,
Shannon M <shanbo1926@gmail.com> wrote:

> On Jul 23, 12:28?am, Neolibertarian <cognac...@gmail.com> wrote:
> > In article
> > <dc453b5c-d9dd-44b0-a3c6-7c6bea635...@z7g2000vbp.googlegroups.com>,
> >
> > ?Raymond <Bluerhy...@aol.com> wrote:
> > > The Grand Experiment Known As America Is Over..In American Politics
> > > the grand experiment has failed. Sadly, ?it is pretty much the end of
> > > America's grand colonial experiment
> >
> > You have to beware those premature autopsies.
> >
> >
> >
> > > Now we?re officially a Corporatocracy. The politicians have decided to
> > > end the grand American experiment in representative government
> >
> > "They" did no such thing.
> >
> > They did what you told them to do. What I told them to do. What We the
> > People told them to do.
> >
> > If this "experiment" fails, it won't be /their/ fault.
>
> Correct. It will be yours and the other rightards

Friend, my views make all the "rightards" look like Maoists.

> who put them into
> office to create this mess.

There's the Party of Devils, and then there's the Party of Angels. Is
that what you're trying to convey?

I warn you, all the historical evidence is stacked against such a naive
assumption--Stubborn, though I know such opinions are these days.

It's pretty obvious the political class in the US has yet to understand
anything at all about the Tea Party.

It's not a political party, of course. It has no members. It has no
actual candidates. It therefore can't be measured in any reliable sense.

Except on election day.

If there's hope for the Republic, it lies with them.

--
Neolibertarian

"Global Warming: It ain't the heat, it's the stupidity."

Raymond

7/23/2011 8:05:00 PM

0

On Jul 23, 2:55 pm, Neolibertarian <cognac...@gmail.com> wrote:
> In article
> <c9e2c20c-b56d-4847-bf04-9c7269f67...@h7g2000prf.googlegroups.com>,
>  Shannon M <shanbo1...@gmail.com> wrote:
>
>
>
>
>
> > On Jul 23, 12:28 am, Neolibertarian <cognac...@gmail.com> wrote:
> > > In article
> > > <dc453b5c-d9dd-44b0-a3c6-7c6bea635...@z7g2000vbp.googlegroups.com>,
>
> > >  Raymond <Bluerhy...@aol.com> wrote:
> > > > The Grand Experiment Known As America Is Over..In American Politics
> > > > the grand experiment has failed. Sadly,  it is pretty much the end of
> > > > America's grand colonial experiment
>
> > > You have to beware those premature autopsies.
>
> > > > Now we¹re officially a Corporatocracy. The politicians have decided to
> > > > end the grand American experiment in representative government
>
> > > "They" did no such thing.
>
> > > They did what you told them to do. What I told them to do. What We the
> > > People told them to do.
>
> > > If this "experiment" fails, it won't be /their/ fault.
>
> > Correct.  It will be yours and the other rightards
>
> Friend, my views make all the "rightards" look like Maoists.
>
> > who put them into
> > office to create this mess.
>
> There's the Party of Devils, and then there's the Party of Angels. Is
> that what you're trying to convey?
>
> I warn you, all the historical evidence is stacked against such a naive
> assumption--Stubborn, though I know such opinions are these days.
>
> It's pretty obvious the political class in the US has yet to understand
> anything at all about the Tea Party.
>
> It's not a political party, of course. It has no members. It has no
> actual candidates. It therefore can't be measured in any reliable sense.
>
> Except on election day.
>
> If there's hope for the Republic, it lies with them.

A Republic, if you can keep it
No one can deny that somewhere along the way, America changed
direction, both domestically and internationally.
by Jacob G. Hornberger, November 2001

AT THE CLOSE OF THE CONSTITUTIONAL CONVENTION, a woman asked Benjamin
Franklin what type of government the Constitution was bringing into
existence. Franklin replied, “A republic, if you can keep it.”

Regardless of one’s judgment concerning the type of government that
the Constitution brought into existence in 1787, no one can deny that
it was truly the most unusual and radical in history.

Consider: With the tragic exception of slavery, the United States was
a society in which people could, by and large, engage in any
occupation or economic enterprise without a government license,
permit, or regulation.

Where people could travel anywhere in the world without restriction
(no passports) and trade with whomever they pleased without the
permission of their government officials.

Where people could accumulate unlimited amounts of wealth without
government interference, because the Constitution did not permit the
government to levy taxes on income.

Where people were free to do whatever they wanted with their own money
— save, spend, donate, invest, hoard, or even destroy it.

Where government was not permitted to take care of people — no Social
Security, Medicare, Medicaid, welfare, education grants, or foreign
aid.

With a few exceptions (e.g., 1850s Massachusetts), there were no
compulsory public (i.e., government) school systems.

No wars on drugs, poverty, or wealth.

And open borders for the free immigration of people from anywhere in
the world.

Like I say, regardless of how you might feel about the political and
economic philosophy of the Founders of our country, no one can deny
that the political and economic system that they brought into
existence was the most unusual and radical in history.

Our Founders’ philosophy toward foreign affairs was also an unusual
one. A primary responsibility of the U.S. government, they believed,
was to protect the nation from invasion or attack and not involve
itself in the affairs or conflicts of other nations.

The Founders clearly understood that horrible things would be seen all
over the world, such as brutal tyrannies and cruel dictatorships —
after all, they themselves had only recently been the victims of the
brutality and cruelty of the British Empire.

But they believed that the best gift that America could give to the
world would be a model for a free, peaceful, harmonious, and
prosperous society — a beacon for the rest of the world to follow. And
they believed that that goal would be not be served if their
government had the imperial power to straighten out messes all over
the world.

Here’s what George Washington counseled to all succeeding generations
of Americans in his Farewell Address:

“The great rule of conduct for us, in regard to foreign nations is in
extending our commercial relations to have with them as little
political connection as possible.... Europe has a set of primary
interests which to us have none, or a very remote relation. Hence she
must be engaged in frequent controversies, the causes of which are
essentially foreign to our concerns.... Why quit our own to stand upon
foreign ground? Why, by interweaving our destiny with that of any part
of Europe, entangle our peace and prosperity in the toils of European
ambition, rivalship, interest, humor, or caprice?”

Celebrating American freedom on July 4, 1821, U.S. Secretary of State
John Quincy Adams delivered a speech to the U.S. House of
Representatives setting forth the vision of the American republic:

She has abstained from interference in the concerns of others, even
when conflict has been for principles to which she clings, as to the
last vital drop that visits the heart.... She goes not abroad, in
search of monsters to destroy. She is the well-wisher to the freedom
and independence of all. She is the champion and vindicator only of
her own.... She well knows that by once enlisting under other banners
than her own, were they even the banners of foreign independence ...
the fundamental maxims of her policy would insensibly change from
liberty to force.... She might become the dictatress of the world.
Thus, when our 18th- and 19th-century ancestors celebrated the Fourth
of July each year, the concept of freedom that they were celebrating
was totally different from the concept of freedom that Americans today
celebrate on the Fourth. The freedom they celebrated involved a way of
life in which government had little power to take their money,
regulate their peaceful activities, or take care of them. It was also
a freedom arising out of their government’s noninterference in the
conflicts of foreign nations.

No one can deny that somewhere along the way, America changed
direction, both domestically and internationally. How about a national
debate as to which vision — the vision of Washington, Adams, Franklin,
and Madison, or that of Wilson, Roosevelt, Johnson, and Nixon — should
guide our nation into its third century of existence?

http://www.fff.org/freedom...


> --
> Neolibertarian
>
> "Global Warming: It ain't the heat, it's the stupidity."- Hide quoted text -
>
> - Show quoted text -

Siobhan Medeiros

7/23/2011 8:43:00 PM

0

On Jul 23, 11:16 am, Raymond <Bluerhy...@aol.com> wrote:
> On Jul 23, 3:28 am, Neolibertarian <cognac...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > In article
> > <dc453b5c-d9dd-44b0-a3c6-7c6bea635...@z7g2000vbp.googlegroups.com>,
>
> >  Raymond <Bluerhy...@aol.com> wrote:
> > > The Grand Experiment Known As America Is Over..In American Politics
> > > the grand experiment has failed. Sadly,  it is pretty much the end of
> > > America's grand colonial experiment
>
> > You have to beware those premature autopsies.
>
> > > Now we¹re officially a Corporatocracy. The politicians have decided to
> > > end the grand American experiment in representative government
>
> > "They" did no such thing.
>
> > They did what you told them to do. What I told them to do. What We the
> > People told them to do.
>
> > If this "experiment" fails, it won't be /their/ fault.
>
> > --
> > Neolibertarian
>
> > "Global Warming: It ain't the heat, it's the stupidity."
>
> Consider This
> How intelligent should ideal voters be?
>
> Voting may be meaningless at times.. In the Bush/Gore election
> millions of voters' vote meant nothing. In the end, one Supreme Court
> vote  (5 to 4) put the worst candidate into the White House because he
> was the most likely to obey the real leaders of this nation... the oil
> company executives , the military industrial complex and the
> wealthiest 2 or 3  % of Americans
>
> Should Everyone be Allowed to Vote?
> Mar 18th, 2011
> The 74th smartest person in the world voices his views about whether
> EVERYONE should be allowed to vote!
>
> Should some people in society (other than those in jail or otherwise
> restricted) be restricted from voting? This is a topic I’ve thought
> about before.  It was brought to my attention again by a reader in the
> comment section of this thread:
>
> http://nosuchthingasanopinion.weebly.com/1/post/2010/11/oba......
>
> The reader wondered whether the tendency of women to vote differently
> than men might be harming society overall. So, I decided to tackle
> this issue, looking not just at women, but looking at other groups,
> including men.
>
> At this point, some people might be offended by the idea of even
> restricting voting.  It’s not something you hear often.  But I will
> argue that once you think about the logic, it’s a very logical
> argument.
>
> First, you’d need to determine whether it’s even potentially
> beneficial to allow only certain people to vote.  I would argue that
> restricting voting to certain persons is one of the most important
> things a society could do for the overall benefit of society.
>
> How many things are more important than voting? You are choosing the
> government…the people are choosing who will govern them!  In the case
> of the US, they are choosing who will manage the collection and
> disbursement of the largest pool of money in history! Taxpayer money!
> Shouldn’t it be of the utmost importance to choose the best people to
> govern us, to spend our taxpayer money?
>
> Now, ask yourself this: Do you think there are any people that are
> misinformed, unknowledgeable, or not intelligent enough to make an
> ideal voting decision?
>
> Of course there are. There are many! This is evidenced solely by the
> fact that many people vote for people based on their personality, even
> when warning signs are available! Two examples of this are: 1) the
> election of Hitler even though Mein Kampf had already been published
> and 2) the election of Obama, even though his anti-American actions
> and associations-to say nothing of his extreme policies-were highly
> public. I'm sure there are many more examples of this phenomenon.
>

<SNIP>

Any article which claims these two cases are even remotely equivalent
can be safely ignored.

Just goes to show you, all the IQ in the world won't help you if
you're ignorant.


Thank you, the fascist lobby has now been heard.

Nobody

7/23/2011 11:59:00 PM

0

Shannon Mitchell aka Siobhan Medeiros aka Mitch the Usenet Bitch
wrote:

> Just goes to show you, all the IQ in the world won't help you if
> you're ignorant.

You are living proof of that Mitch.

Siobhan Medeiros (Shannon Mitchell) Work: Always On UPS Systems, #100 - 150 Campion Rd, Kelowna, BC,

7/24/2011 4:52:00 AM

0

The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"


On Sun, 27 Jul 2008 13:47:16 -0700 (PDT), Siobhan Medeiros
<sbm2006@shaw.ca> wrote:
>On Jul 26, 2:30 pm, Patriot Games <Patr...@America.Com> wrote:
>> >Wrong. Canadians pay less, not more in taxes for their healthcare.
>> PROVEN wrong:
>> http://www.nationmaster.com/graph/tax_com_of_tax_cor_inc_ta......
>> corporate-income-tax
>> Taxation Statistics > Components of taxation > Corporate income tax
>> (most recent) by country
>> #10 Canada: 10.1%
>> #20 United States: 6.7%
>Good for us! Nothing to do with health care, though.

You're a proven fool.

>> Taxation Statistics > Components of taxation > Goods and service tax
>> (most recent) by country
>> #25 Canada: 26.3%
>> #30 United States: 17.6%
>Still nothing to do with health care.

You're a proven fool.

>> Taxation Statistics > Components of taxation > Personal income tax
>> (most recent) by country
>> #5 United States: 37.7%
>> #6 Canada: 35%
>Um....nothing to do with income tax..

You're a proven fool.

>> Taxation Statistics > Components of taxation > Property tax (most
>> recent) by country
>> #3 United States: 10.1%
>> #4 Canada: 9.7%
>Still nothing to do with health care.

You're a proven fool.

>> Taxation Statistics > Tax Freedom Day > Date of Year (most recent) by
>> country
>> United States 30 April
>> Canada 19 June
>LOL! Total bullshit from the Fraser Institute, AND nothing to do with
>health care.

You're a proven fool.

>> >Americans pay almost twice what we do, and with insurance costs on top
>> >of that.
>> See above, 'Tard.
>See what? You didn't post a damn thing about health care! Retard.

Taxes paid to the Canadian gov't.

Canadian gov't provides healthcare...

You're a proven fool.

I have sufficiently humiliated you, in public.

Now I am finished with you.

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...

Siobhan Medeiros (Shannon Mitchell) Work: Always On UPS Systems, #100 - 150 Campion Rd, Kelowna, BC,

7/24/2011 4:53:00 AM

0

The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"


On Wed, 22 Oct 2008 22:39:50 -0700 (PDT), Siobhan Medeiros
<sbm2006@shaw.ca> wrote:
>On Oct 22, 10:55?am, "M. MacDonald" <mmacdon...@bc.cc.ca.us> wrote:
>> Wonder how much the taxpayers have spent on cigarettes for Obama - and will
>> continue to spend?
>> The guy has no backbone to quit...
>Actually, he did quit.

Actually, you're a Canadian Cocklip Liar.

Obama Admits Smoking Cigarettes in Last Few Months
June 10, 2008
http://blogs.abcnews.com/politicalradar/2008/06/obama-admi...

Video: http://abcnews.go.com/Video/playerIndex?...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...

Neolibertarian

7/24/2011 11:14:00 AM

0

In article
<5d449525-9977-4e40-8f6c-13342dd8c778@l18g2000vbe.googlegroups.com>,
Raymond <Bluerhymer@aol.com> wrote:

> Thus, when our 18th- and 19th-century ancestors celebrated the Fourth
> of July each year, the concept of freedom that they were celebrating
> was totally different from the concept of freedom that Americans today
> celebrate on the Fourth. The freedom they celebrated involved a way of
> life in which government had little power to take their money,
> regulate their peaceful activities, or take care of them. It was also
> a freedom arising out of their government?s noninterference in the
> conflicts of foreign nations.
>
> No one can deny that somewhere along the way, America changed
> direction, both domestically and internationally. How about a national
> debate as to which vision ? the vision of Washington, Adams, Franklin,
> and Madison, or that of Wilson, Roosevelt, Johnson, and Nixon ? should
> guide our nation into its third century of existence?

That national debate has never ceased.

These summaries and highlights included in the article you pasted as
response here, are somewhat deceptive. The lines and "visions" are not
as clear as you imagine.

Divided government isn't an ideal; it's a pragmatic compromise.

Hence, the endless debate since 1787 on the role of federal
government--the debate over the Louisiana Purchase continues today in
the arguments over the federal debt and Health Care Reform.

I would argue this debate isn't so much over the vision of our public
servants (Washington, Adams, Madison, Wilson, Roosevelt, Johnson and
Nixon--and all those thousands not mentioned) so much as the vision of
We the People.

--
Neolibertarian

"Global Warming: It ain't the heat, it's the stupidity."