Home > other >  Tushare financial library notice_content function cannot return the correct results suggest the list
Tushare financial library notice_content function cannot return the correct results suggest the list

Time:09-26

Notice_content mines used to return to the stock information content, now I am using version will return an error "list index out of range", by adjusting the content change function, do the correction on this question, we record, processing steps are as follows:
1, find the python installation directory: \ Lib \ site - packages \ tushare \ stock folder
2, find notice_content file newsevent. Py
3, original content is:
Try:
HTML=LXML. HTML. Parse (url)
Res=HTML. Xpath ('//div [@ id=\ "content \]/pre/text () ')
Return res. Strip ()
Except the Exception as er:
Print (STR) (er)
Is amended as:
Try:
HTML=LXML. HTML. Parse (url)
Cont=HTML. Xpath ('//div [@ id=\ "content \]/p/text () ')
Res='
For loop_num in range (0, len (cont) :
Res=res + cont [loop_num]. Strip ()
Return res
Except the Exception as er:
Print (STR) (er)
4, after the changes, save and exit the python, re-enter the import tushare can come into effect, the modified normal announcement content string,
  • Related