connect to https unpossible. Please help.

Discussion in 'Python' started by Mark Delon, Oct 19, 2005.

  1. Mark Delon

    Mark Delon Guest

    Hi,

    i want to log via python script to https page:

    'https://brokerjet.ecetra.com/at/'
    #
    But it does not work.

    I am using following code(see below)

    Has somebody any ideas?
    How can I get to this https page?
    Need I to know some infos from "provider"(certificates, etc)?
    Thank u very much !

    sincerely mark

    Code:
    ======
    import urllib2

    theurl='https://brokerjet.ecetra.com/at/'
    #
    username = 'username'
    password = 'password'
    passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
    passman.add_password(None, theurl, username, password)
    authhandler = urllib2.HTTPBasicAuthHandler(passman)
    opener = urllib2.build_opener(authhandler)
    urllib2.install_opener(opener)
    t = urllib2.urlopen('https://brokerjet.ecetra.com/at/')
    #
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "C:\Program Files\python233\lib\urllib2.py", line 129, in urlopen
    return _opener.open(url, data)
    File "C:\Program Files\python233\lib\urllib2.py", line 326, in open
    '_open', req)
    File "C:\Program Files\python233\lib\urllib2.py", line 306, in _call_chain
    result = func(*args)
    File "C:\Program Files\python233\lib\urllib2.py", line 908, in https_open
    return self.do_open(httplib.HTTPS, req)
    File "C:\Program Files\python233\lib\urllib2.py", line 886, in do_open
    raise URLError(err)
    urllib2.URLError: <urlopen error (10060, 'Operation timed out')>


    --
    Highspeed-Freiheit. Bei GMX supergünstig, z.B. GMX DSL_Cityflat,
    DSL-Flatrate für nur 4,99 Euro/Monat* http://www.gmx.net/de/go/dsl
     
    Mark Delon, Oct 19, 2005
    #1
    1. Advertising

  2. Mark Delon

    Tim Roberts Guest

    "Mark Delon" <> wrote:
    >
    >i want to log via python script to https page:
    >
    >'https://brokerjet.ecetra.com/at/'
    >#
    >But it does not work.
    >
    >I am using following code(see below)
    >
    >Has somebody any ideas?
    >How can I get to this https page?
    >Need I to know some infos from "provider"(certificates, etc)?
    >Thank u very much !


    You are trying to set this up to use HTTP BasicAuth authorization, but this
    page is not using HTTP authorization. You can recognize HTTP authorization
    by the separate browser window that pops up to ask for your username and
    password.

    In this case, the username and password fields are just ordinary fields on
    a form. What you need to do is read the HTTP on that page, and figure out
    how to send a URL containing values for those fields. In this case, the
    form data goes to
    https://brokerjet.ecetra.com/at/welcome/loginaction.phtml, and you'll need
    to encode 'login' and 'pwd' fields in the POST data.

    However, that isn't the end of your trouble. That page will almost
    certainly send you a cookie, which you will need to send back with every
    request.
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Oct 21, 2005
    #2
    1. Advertising

  3. Mark Delon

    Mark Delon Guest

    Hi Tim,

    really than u very much!

    I think u have helped me!

    I will try, that what u said.

    I have found probably simplier solution.
    Is it so?

    ....but without success:-(.

    I want to download some URLs via python script.
    With some URLs I have success with some NOT.
    Why?
    I do following:
    ===============
    1. Login to https://brokerjet.ecetra.com/at/welcome/register/loginpage.phtml
    via Mozzila browser
    2. I try to download some URLs using cookies: see script bellow:
    3. Some pages works (e.g. news, but on some pages I get:
    --
    Traceback (most recent call last):
    File "test_stock.py", line 11, in ?
    r =
    opener.open("https://brokerjet.ecetra.com/at/trading/wt.phtml?isin=NL0000240000&exid=ETR")
    File "C:\Programme\Python24\lib\urllib2.py", line 358, in open
    response = self._open(req, data)
    File "C:\Programme\Python24\lib\urllib2.py", line 376, in _open
    '_open', req)
    File "C:\Programme\Python24\lib\urllib2.py", line 337, in _call_chain
    result = func(*args)
    File "C:\Programme\Python24\lib\urllib2.py", line 1029, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
    File "C:\Programme\Python24\lib\urllib2.py", line 996, in do_open
    raise URLError(err)
    urllib2.URLError: <urlopen error (10061, 'Connection refused')>

    Details- Script:
    =================
    I make login via Mozilla browser

    import os, cookielib, urllib2

    cj = cookielib.MozillaCookieJar()
    os.environ['HOME']= r"C:\tmp\COOKIE"
    cj.load(os.path.join(os.environ["HOME"], "cookies.txt"))
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    # first URLs download works
    r =
    opener.open("http://brokerjet.ecetra.com/at/news/index.phtml?notation=7536885")
    # second URLs download DOES NOT work ... WHY?
    r =
    opener.open("https://brokerjet.ecetra.com/at/trading/wt.phtml?isin=NL0000240000&exid=ETR")
    #
    h = r.readlines()
    g = open("test.html","w")
    g.writelines(h)
    g.close()
    os.system("test.html")

    Thans realy for all ideas!


    sincerely
    mark

    > --- Ursprüngliche Nachricht ---
    > Von: Tim Roberts <>
    > An:
    > Betreff: Re: connect to https unpossible. Please help.
    > Datum: Fri, 21 Oct 2005 06:05:45 GMT
    >
    > "Mark Delon" <> wrote:
    > >
    > >i want to log via python script to https page:
    > >
    > >'https://brokerjet.ecetra.com/at/'
    > >#
    > >But it does not work.
    > >
    > >I am using following code(see below)
    > >
    > >Has somebody any ideas?
    > >How can I get to this https page?
    > >Need I to know some infos from "provider"(certificates, etc)?
    > >Thank u very much !

    >
    > You are trying to set this up to use HTTP BasicAuth authorization, but
    > this
    > page is not using HTTP authorization. You can recognize HTTP
    > authorization
    > by the separate browser window that pops up to ask for your username and
    > password.
    >
    > In this case, the username and password fields are just ordinary fields on
    > a form. What you need to do is read the HTTP on that page, and figure out
    > howfiues for those fields. In this case, the
    > form data goes to
    > https://brokerjet.ecetra.com/at/welcome/loginaction.phtml, and you'll need
    > to encode 'login' and 'pwd' fields in the POST data.
    >
    > However, that isn't the end of your trouble. That page will almost
    > certainly send you a cookie, which you will need to send back with every
    > request.
    > --
    > - Tim Roberts,
    > Providenza & Boekelheide, Inc.
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >


    --
    Telefonieren Sie schon oder sparen Sie noch?
    NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie
     
    Mark Delon, Oct 21, 2005
    #3
    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. Subra Mallampalli
    Replies:
    0
    Views:
    433
    Subra Mallampalli
    Oct 2, 2003
  2. KK
    Replies:
    2
    Views:
    596
    Big Brian
    Oct 14, 2003
  3. Axel
    Replies:
    8
    Views:
    1,106
    Adrienne Boswell
    Apr 27, 2009
  4. jotto
    Replies:
    4
    Views:
    394
    jotto
    Oct 2, 2006
  5. Naveen Dhanuka
    Replies:
    1
    Views:
    287
Loading...

Share This Page