Want some information....

Discussion in 'Ruby' started by Arun Kumar, May 12, 2009.

  1. Arun Kumar

    Arun Kumar Guest

    Hi,
    I want to know about authentication in ruby. Is it possible to scrap
    html of those sites which require basic authentication.

    eg. I want to scrap the profile html page of a user. But in order to get
    to that page I need to enter the username and password. Now if I'm using
    'net/http' to scrap the contents of the profile page, how can I
    implement the same. Is it possible in ruby to scrap web pages for which
    the user need to enter the username and password.

    Please help

    N. B. - providing link to any documentation which states this problem
    will be really helpfull.


    Regards
    Arun
    --
    Posted via http://www.ruby-forum.com/.
     
    Arun Kumar, May 12, 2009
    #1
    1. Advertising

  2. 2009/5/12 Arun Kumar <>:
    > =A0 I want to know about authentication in ruby. Is it possible to scrap
    > html of those sites which require basic authentication.


    I am not a native speaker but for all I know "want" is considered
    impolite among English speaking people.

    > N. B. - providing link to any documentation which states this problem
    > will be really helpfull.


    What did your research turn up? Did you check the standard library's
    documentation in the well known place?

    Regards

    robert


    --=20
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
     
    Robert Klemme, May 12, 2009
    #2
    1. Advertising

  3. Arun Kumar

    Arun Kumar Guest

    Robert Klemme wrote:
    > 2009/5/12 Arun Kumar <>:
    >> � I want to know about authentication in ruby. Is it possible to scrap
    >> html of those sites which require basic authentication.

    >
    > I am not a native speaker but for all I know "want" is considered
    > impolite among English speaking people.
    >
    >> N. B. - providing link to any documentation which states this problem
    >> will be really helpfull.

    >
    > What did your research turn up? Did you check the standard library's
    > documentation in the well known place?
    >
    > Regards
    >
    > robert


    Hi
    Thanks for the quick reply. Sorry for the impolite statement.

    require 'net/http'

    Net::HTTP.start('www.example.com') {|http|
    req = Net::HTTP::Get.new('/secret-page.html')
    req.basic_auth 'account', 'password'
    response = http.request(req)
    print response.body
    }

    This is the phrase which I got from the ruby-doc site. I dont know
    whether this is helpfull or not. That's why I asked such a doubt. Please
    give me a general guidance for this issue.

    Thanks

    Arun Kumar
    --
    Posted via http://www.ruby-forum.com/.
     
    Arun Kumar, May 12, 2009
    #3
  4. On Tue, May 12, 2009 at 9:06 AM, Arun Kumar
    <> wrote:
    > Robert Klemme wrote:
    >> 2009/5/12 Arun Kumar <>:
    >>> =EF=BF=BD I want to know about authentication in ruby. Is it possible t=

    o scrap
    >>> html of those sites which require basic authentication.

    >>
    >> I am not a native speaker but for all I know "want" is considered
    >> impolite among English speaking people.
    >>
    >>> N. B. - providing link to any documentation which states this problem
    >>> will be really helpfull.

    >>
    >> What did your research turn up? =C2=A0Did you check the standard library=

    's
    >> documentation in the well known place?
    >>
    >> Regards
    >>
    >> robert

    >
    > Hi
    > =C2=A0Thanks for the quick reply. Sorry for the impolite statement.
    >
    > =C2=A0require 'net/http'
    >
    > =C2=A0 =C2=A0Net::HTTP.start('www.example.com') {|http|
    > =C2=A0 =C2=A0 =C2=A0req =3D Net::HTTP::Get.new('/secret-page.html')
    > =C2=A0 =C2=A0 =C2=A0req.basic_auth 'account', 'password'
    > =C2=A0 =C2=A0 =C2=A0response =3D http.request(req)
    > =C2=A0 =C2=A0 =C2=A0print response.body
    > =C2=A0 =C2=A0}
    >
    > This is the phrase which I got from the ruby-doc site. I dont know
    > whether this is helpfull or not. That's why I asked such a doubt. Please
    > give me a general guidance for this issue.


    Well did you try it?

    If it didn't work, did you make the correct substitutions for
    'account' and 'password' ?


    --=20
    Rick DeNatale

    Blog: http://talklikeaduck.denhaven2.com/
    Twitter: http://twitter.com/RickDeNatale
    WWR: http://www.workingwithrails.com/person/9021-rick-denatale
    LinkedIn: http://www.linkedin.com/in/rickdenatale
     
    Rick DeNatale, May 12, 2009
    #4
  5. Arun Kumar

    Arun Kumar Guest

    Rick Denatale wrote:
    > On Tue, May 12, 2009 at 9:06 AM, Arun Kumar
    > <> wrote:
    >>>

    >>  require 'net/http'
    >> give me a general guidance for this issue.

    > Well did you try it?

    Hi,
    Thanks for the reply.
    Well, I didn't try it. I want to try it of course but before that I want
    to know how such pages can be accessed. That's why I asked for some
    guidance.

    Arun
    --
    Posted via http://www.ruby-forum.com/.
     
    Arun Kumar, May 13, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Cobban
    Replies:
    9
    Views:
    430
    Roedy Green
    Apr 18, 2004
  2. Benny Ng
    Replies:
    1
    Views:
    553
    bruce barker
    Jan 4, 2007
  3. ashu

    just want detail information

    ashu, Apr 22, 2007, in forum: C Programming
    Replies:
    16
    Views:
    449
    Army1987
    Apr 24, 2007
  4. Replies:
    4
    Views:
    181
    Ted Zlatanov
    Sep 13, 2006
  5. pavi
    Replies:
    0
    Views:
    1,395
Loading...

Share This Page