
    fi                         d Z ddlZddlmZ ddlmZ ddlZddlZddlm	Z	 dej
        fdZedk    r e            Z ee           dS dS )	ug   
Date: 2024/4/29 17:00
Desc: 人民币汇率中间价
https://www.safe.gov.cn/safe/rmbhlzjj/index.html
    N)datetime)StringIO)BeautifulSoupreturnc                     d} t          j        |           }d|_        t          |j        d          }|                    dt          j        d                    d         }d	| } t          j	        |           }|
                    d
gd           |                    dd           t          j        |d
                                         d                   t          j        d          z                                                       d          d         }t#          j                                                                        d          d         }d} ||dd}t          j        | |          }t          j        t+          |j                            d         }|
                    d
gd           |                    dd           t          j        ||gd          }	|	j        dd         }
|
D ]!}t          j        |	|         d          |	|<   "t          j        |	d
         d          j        j        |	d
<   |	S )u   
    人民币汇率中间价
    https://www.safe.gov.cn/safe/rmbhlzjj/index.html
    :return: 人民币汇率中间价
    :rtype: pandas.DataFrame
    z1https://www.safe.gov.cn/safe/2020/1218/17833.htmlutf8lxml)featuresau   人民币汇率)namestringhrefzhttps://www.safe.gov.cnu   日期T)byinplace)r   drop   )daysTr   z5https://www.safe.gov.cn/AppStructured/hlw/RMBQuery.dotrue)	startDateendDatequeryYN)data)objsignore_indexNcoerce)errors)requestsgetencodingr   textfindrecompilepd
read_excelsort_valuesreset_index	Timestamptolist	Timedelta	isoformatsplitr   nowpost	read_htmlr   concatcolumns
to_numericto_datetimedtdate)urlrsoupcontenttemp_df
start_dateend_datepayloadcurrent_temp_dfbig_dfcolumn_name_listitems               I/usr/local/lib/python3.11/dist-packages/akshare/currency/currency_safe.pycurrency_boc_saferE      s-    >CSAAJ&111DiiS4E)F)FiGGOG
-G
-
-CmC  GH:t4444000	gh'..004	5	5!8L8L8L	L		sA	 
 |~~''))//44Q7H
AC G
 	c(((Al8AF#3#344R8OH:t<<<4888YWo6TJJJF~abb)  D D}VD\(CCCt~fX&6xHHHKPF8M    __main__)__doc__r$   r   ior   pandasr&   r   bs4r   	DataFramerE   __name__currency_boc_safe_dfprint rF   rD   <module>rQ      s     
			                       %2< % % % %P z,,..	E
 rF   