ServerPortfolio  2.0
Python parsers and server
 All Classes Namespaces Files Functions Variables Properties Pages
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
serverportfolio.Parsers.Parser_Bourso.Parser_Bourso Class Reference

Specific parser for querying the Boursorama website, only for instantaneous data. More...

Inheritance diagram for serverportfolio.Parsers.Parser_Bourso.Parser_Bourso:
Inheritance graph
[legend]
Collaboration diagram for serverportfolio.Parsers.Parser_Bourso.Parser_Bourso:
Collaboration graph
[legend]

Public Member Functions

def __init__
 Constructor. More...
 
def create_url
 Create the url with the code of the stock. More...
 
def parse
 Parse the html page, specific to instantaneous values. More...
 
- Public Member Functions inherited from serverportfolio.Parsers.Abstract.AbstractParser
def __init__
 Constructor. More...
 
def create_url
 Store links to stocks to update, dictionary 'symbol' : Stock object. More...
 
def parse
 Parse the text file (html, CSV,...) More...
 
def run_parser
 Main function to call for running the parser. More...
 
def clean
 Reset internal data members after a parsing. More...
 
def store_stock_copy
 Make a local copy of the Stock objects (linked of the original in DictionaryStocks in fact) into a local dictionary. More...
 
def update_stock
 Update the local stocks with the new retrieved data. More...
 
def get_symbol_from_code
 Retrieve the symbol (or Stock) from the code_yahoo or code_bourso. More...
 

Public Attributes

 logger
 
 source
 
 url
 
 list_return_data
 
- Public Attributes inherited from serverportfolio.Parsers.Abstract.AbstractParser
 url
 save url, useful for reporting errors and exceptions More...
 
 e_action
 enumeration (EAction) of the type of query to perform More...
 
 option_post
 
 local_stock
 
 list_return_data
 

Static Public Attributes

dictionary dict_record
 Make the correspondence between the html page and the template InstValue. More...
 

Private Member Functions

def _extract_data
 Extract the instantaneous values from the main lxml etree table. More...
 
def _extract_data_generic
 Generic version to parse values, extract the last text() from a td entry. More...
 
def _extract_number
 General function to extract all numbers ( price, volume...) More...
 
def _extract_data_value
 Specific to extract the value and the state of the stock (OPEN/CLOSED). More...
 
def _extract_data_dernier
 Specific to get the date and time of the dernier echange. More...
 

Static Private Attributes

string __INSTVALUE_STOCK_URL = "http://www.boursorama.com/cours.phtml?symbole="
 url format for boursorama, to complete with code_bourso More...
 

Detailed Description

Specific parser for querying the Boursorama website, only for instantaneous data.

Parse HTML Page of Boursorama: last value, volume, highest, lowest of the day, OPEN or CLOSED state...

Definition at line 29 of file Parser_Bourso.py.

Constructor & Destructor Documentation

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.__init__ (   self,
  action 
)

Constructor.

Parameters
e_actionEAction to perform, only InstValue with Boursorama

Definition at line 48 of file Parser_Bourso.py.

Member Function Documentation

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data (   self,
  name,
  table,
  dict_inst_value 
)
private

Extract the instantaneous values from the main lxml etree table.

Parameters
nameof the data to extract, defined in self.dict_record
tableetree table containing all data
dict_inst_valuetemplate to fill

Definition at line 131 of file Parser_Bourso.py.

References serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_dernier(), serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_generic(), serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_value(), and serverportfolio.Parsers.Abstract.AbstractParser.local_stock.

Here is the call graph for this function:

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_dernier (   self,
  table 
)
private

Specific to get the date and time of the dernier echange.

Parameters
tableof instantaneous values extracted by xpath
Returns
tupe(date, time) in string format

Definition at line 247 of file Parser_Bourso.py.

References serverportfolio.Parsers.Abstract.AbstractParser.url.

Referenced by serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data().

Here is the caller graph for this function:

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_generic (   self,
  name,
  table 
)
private

Generic version to parse values, extract the last text() from a td entry.

Volume not present with devise, throw an exception and fill with default 0, nan (??)

Parameters
nameof the td entry to extract
tableof instantaneous values extracted by xpath
Returns
value extracted

Definition at line 178 of file Parser_Bourso.py.

References serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_number(), and serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.dict_record.

Referenced by serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data().

Here is the call graph for this function:

Here is the caller graph for this function:

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_value (   self,
  table 
)
private

Specific to extract the value and the state of the stock (OPEN/CLOSED).

Parameters
tableof instantaneous values extracted by xpath
Returns
tuple(value, state)

Definition at line 222 of file Parser_Bourso.py.

References serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_number().

Referenced by serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data().

Here is the call graph for this function:

Here is the caller graph for this function:

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_number (   self,
  line 
)
private

General function to extract all numbers ( price, volume...)

Parameters
linestring in input
Returns
the corrected string

Definition at line 211 of file Parser_Bourso.py.

Referenced by serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_generic(), and serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_value().

Here is the caller graph for this function:

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.create_url (   self)

Create the url with the code of the stock.

Assert that only one Stock is provided in input (Parser dependent)

Definition at line 56 of file Parser_Bourso.py.

References serverportfolio.Parsers.Abstract.AbstractParser.local_stock.

def serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.parse (   self,
  html_page 
)

Parse the html page, specific to instantaneous values.

Extract data from the complete html page to self.list_return_data (list not created, only one stock)

Parameters
html_pagethe html page returned by UtilsParsers.web_query

Definition at line 77 of file Parser_Bourso.py.

Member Data Documentation

string serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.__INSTVALUE_STOCK_URL = "http://www.boursorama.com/cours.phtml?symbole="
staticprivate

url format for boursorama, to complete with code_bourso

Definition at line 44 of file Parser_Bourso.py.

dictionary serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.dict_record
static
Initial value:
1 = {
2  'value': ['Cours'], #,0/1
3  'variation': ['Variation'],
4  'dernier echange': ['Dernier'],
5  'volume': ['Volume '],
6  'ouverture': ['Ouverture'],
7  'plushaut': ['+ Haut'],
8  'plusbas' : ['+ Bas']
9  }

Make the correspondence between the html page and the template InstValue.

0/1, could use for a exact matching or contains function

Definition at line 33 of file Parser_Bourso.py.

Referenced by serverportfolio.Parsers.Parser_Bourso.Parser_Bourso._extract_data_generic().

serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.list_return_data

Definition at line 82 of file Parser_Bourso.py.

serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.logger
serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.source
serverportfolio.Parsers.Parser_Bourso.Parser_Bourso.url

The documentation for this class was generated from the following file: