def __init__(self):
     debug('LiveUpdate_boursorama:__init__')
     self.m_default_host = "www.boursorama.fr"
     self.m_login_url = "https://www.boursorama.fr/logunique.phtml"
     self.m_logged = False
     self.m_cookies = ITradeCookies()
     # Manualy set the cookie that tell boursorama we are a cookie aware browser
     self.m_cookies.set("SUP_COOKIE=OUI")
     self.m_connection = ITradeConnection(
         cookies=None,
         proxy=itrade_config.proxyHostname,
         proxyAuth=itrade_config.proxyAuthentication,
         connectionTimeout=itrade_config.connectionTimeout)
     debug('Boursorama login (%s) - ready to run' % self.m_default_host)
Пример #2
0
 def __init__(self):
     debug("LiveUpdate_boursorama:__init__")
     self.m_default_host = "www.boursorama.fr"
     self.m_login_url = "https://www.boursorama.fr/logunique.phtml"
     self.m_logged = False
     self.m_cookies = ITradeCookies()
     # Manualy set the cookie that tell boursorama we are a cookie aware browser
     self.m_cookies.set("SUP_COOKIE=OUI")
     self.m_connection = ITradeConnection(
         cookies=None,
         proxy=itrade_config.proxyHostname,
         proxyAuth=itrade_config.proxyAuthentication,
         connectionTimeout=itrade_config.connectionTimeout,
     )
     debug("Boursorama login (%s) - ready to run" % self.m_default_host)
Пример #3
0
class Login_boursorama(object):
    def __init__(self):
        debug("LiveUpdate_boursorama:__init__")
        self.m_default_host = "www.boursorama.fr"
        self.m_login_url = "https://www.boursorama.fr/logunique.phtml"
        self.m_logged = False
        self.m_cookies = ITradeCookies()
        # Manualy set the cookie that tell boursorama we are a cookie aware browser
        self.m_cookies.set("SUP_COOKIE=OUI")
        self.m_connection = ITradeConnection(
            cookies=None,
            proxy=itrade_config.proxyHostname,
            proxyAuth=itrade_config.proxyAuthentication,
            connectionTimeout=itrade_config.connectionTimeout,
        )
        debug("Boursorama login (%s) - ready to run" % self.m_default_host)

    # ---[ properties ] ---

    def name(self):
        return "boursorama"

    def desc(self):
        return message("login_boursorama_desc")

    # ---[ userinfo ] ---
    def saveUserInfo(self, u, p):
        f = open(os.path.join(itrade_config.dirUserData, "boursorama_userinfo.txt"), "w")
        s = u + "," + p
        f.write(s)
        f.close()

    def loadUserInfo(self):
        try:
            f = open(os.path.join(itrade_config.dirUserData, "boursorama_userinfo.txt"), "r")
        except IOError:
            return None, None
        s = f.read().strip()
        f.close()
        v = s.split(",")
        if len(v) == 2:
            return v[0].strip(), v[1].strip()
        return None, None

    # ---[ login ] ---

    def login(self, u=None, p=None):
        # load username / password (if required)
        if u == None or p == None:
            u, p = self.loadUserInfo()
            if u == None or p == None:
                print "login: userinfo are invalid - please reenter Access Information"
                return False

        try:
            param = {
                "org": "/index.phtml?",
                "redirect": "",
                "login": u,
                "password": p,
                "memo": "oui",
                "submit2": "Valider",
            }
            buf = self.m_connection.getDataFromUrl(self.m_login_url, data=param)
        except IOError, e:
            print "Exception occured while requesting Boursorama login page : %s" % e
            return False

        print "bourso login response :saved to bourso.html"
        file("bourso.html", "w").write(buf)

        return True
class Login_boursorama(object):
    def __init__(self):
        debug('LiveUpdate_boursorama:__init__')
        self.m_default_host = "www.boursorama.fr"
        self.m_login_url = "https://www.boursorama.fr/logunique.phtml"
        self.m_logged = False
        self.m_cookies = ITradeCookies()
        # Manualy set the cookie that tell boursorama we are a cookie aware browser
        self.m_cookies.set("SUP_COOKIE=OUI")
        self.m_connection = ITradeConnection(
            cookies=None,
            proxy=itrade_config.proxyHostname,
            proxyAuth=itrade_config.proxyAuthentication,
            connectionTimeout=itrade_config.connectionTimeout)
        debug('Boursorama login (%s) - ready to run' % self.m_default_host)

    # ---[ properties ] ---

    def name(self):
        return 'boursorama'

    def desc(self):
        return message('login_boursorama_desc')

    # ---[ userinfo ] ---
    def saveUserInfo(self, u, p):
        f = open(
            os.path.join(itrade_config.dirUserData, 'boursorama_userinfo.txt'),
            'w')
        s = u + ',' + p
        f.write(s)
        f.close()

    def loadUserInfo(self):
        try:
            f = open(
                os.path.join(itrade_config.dirUserData,
                             'boursorama_userinfo.txt'), 'r')
        except IOError:
            return None, None
        s = f.read().strip()
        f.close()
        v = s.split(',')
        if len(v) == 2:
            return v[0].strip(), v[1].strip()
        return None, None

    # ---[ login ] ---

    def login(self, u=None, p=None):
        # load username / password (if required)
        if u == None or p == None:
            u, p = self.loadUserInfo()
            if u == None or p == None:
                print 'login: userinfo are invalid - please reenter Access Information'
                return False

        try:
            param = {
                "org": "/index.phtml?",
                "redirect": "",
                "login": u,
                "password": p,
                "memo": "oui",
                "submit2": "Valider"
            }
            buf = self.m_connection.getDataFromUrl(self.m_login_url,
                                                   data=param)
        except IOError, e:
            print "Exception occured while requesting Boursorama login page : %s" % e
            return False

        print "bourso login response :saved to bourso.html"
        file("bourso.html", "w").write(buf)

        return True