connect to https unpossible. Please help.

M

Mark Delon

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')>
 
T

Tim Roberts

Mark Delon said:
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.
 
M

Mark Delon

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top