jma提要的python客户端库。

jma-feed的Python项目详细描述


JMA馈送

用于JMA feed的python客户端库。

此项目是使用jacebrowning/template-python使用cookiecutter生成的。

Unix Build StatusCoverage StatusScrutinizer Code QualityDocumentation StatusPyPI VersionPyPI License

设置

要求

  • Python3.6+

安装

使用pip安装jma feed:

$ pip install jma-feed

或者直接从源代码:

$ git clone https://github.com/tearoom6/jma-feed.git
$ cd jma-feed
$ python setup.py install

用法

安装后,可以导入包:

importjma_feedjma_feed.__version__

可以从Atom源检索报告:

all_reports=jma_feed.fetch_all_reports(long_term=False)all_meteorology_reports=jma_feed.fetch_all_meteorology_reports(long_term=False)all_seismology_reports=jma_feed.fetch_all_seismology_reports(long_term=False)all_volcanology_reports=jma_feed.fetch_all_volcanology_reports(long_term=False)

报告API:

control=report.controlprint(control.title)print(control.date_time)print(control.status)print(control.editorial_office)print(control.publishing_office)head=report.headprint(head.title)print(head.report_date_time)print(head.target_date_time)print(head.event_id)print(head.info_type)print(head.serial)print(head.info_kind)print(head.info_kind_version)print(head.headline_text)forheadline_informationinhead.headline_information_list:print(headline_information.type)foriteminheadline_information.items:print(item.areas_code_type)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.condition)forareainitem.areas:print(area.name)print(area.code)body=report.body# Meteorologyifisinstance(body,jma_feed.ReportBodyMeteorology):target_area=body.target_areaiftarget_area:print(target_area.name)print(target_area.code)comment=body.commentifcomment:fortextincomment.texts:print(text.text)fornoticeinbody.notices:print(notice)forwarninginbody.warnings:foriteminwarning.items:print(item.change_status)print(item.full_status)print(item.editing_mark)ifitem.area:print(item.area.name)print(item.area.code)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.status)print(kind.condition)formeteorological_infoinbody.meteorological_infos:print(meteorological_info.date_time)print(meteorological_info.duration)print(meteorological_info.name)foriteminmeteorological_info.items:print(item.change_status)print(item.full_status)print(item.editing_mark)ifitem.area:print(item.area.name)print(item.area.code)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.status)print(kind.condition)fortime_series_infoinbody.time_series_infos:fortime_defineinmeteorological_info.time_defines:print(time_define.date_time)print(time_define.duration)print(time_define.name)foriteminmeteorological_info.items:print(item.change_status)print(item.full_status)print(item.editing_mark)ifitem.area:print(item.area.name)print(item.area.code)forkindinitem.kinds:print(kind.name)print(kind.code)print(kind.status)print(kind.condition)# Seismologyifisinstance(body,jma_feed.ReportBodySeismology):print(body.naming)print(body.text)print(body.next_advisory)comments=body.commentsifcommentsandcomments.warning_comment:print(comments.warning_comment.text)print(comments.warning_comment.code)print(comments.warning_comment.code_type)ifcommentsandcomments.forecast_comment:print(comments.forecast_comment.text)print(comments.forecast_comment.code)print(comments.forecast_comment.code_type)ifcommentsandcomments.observation_comment:print(comments.observation_comment.text)print(comments.observation_comment.code)print(comments.observation_comment.code_type)ifcommentsandcomments.var_comment:print(comments.var_comment.text)print(comments.var_comment.code)print(comments.var_comment.code_type)ifcommentsandcomments.free_form_comment:print(comments.free_form_comment)tsunami=body.tsunamiforearthquakeinbody.earthquakes:print(earthquake.origin_time)print(earthquake.arrival_time)print(earthquake.condition)formagnitudeinearthquake.magnitudes:print(magnitude)hypocenter=earthquake.hypocenterifhypocenter:print(hypocenter.source)ifhypocenter.area:print(hypocenter.area.name)print(hypocenter.area.code)print(hypocenter.area.coordinate)# Volcanologyifisinstance(body,jma_feed.ReportBodyVolcanology):print(body.notice)print(body.text)forvolcano_infoinbody.volcano_infos:foriteminvolcano_info.items:ifitem.kind:print(item.kind.name)print(item.kind.formal_name)print(item.kind.code)print(item.kind.condition)forareainitem.areas:print(area.name)print(area.code)print(area.coordinate)forash_infoinbody.ash_infos:print(ash_info.start_time)print(ash_info.end_time)foriteminash_info.items:ifitem.kind:print(item.kind.name)print(item.kind.formal_name)print(item.kind.code)print(item.kind.condition)forareainitem.areas:print(area.name)print(area.code)print(area.coordinate)

馈送API(低级API):

# High-frequency feed# Regular (定時: 気象に関する情報のうち、天気概況など定時に発表されるもの)feed_url=jma_feed.FEED_URL_REGULAR_SHORT_TERM# Extra (随時: 気象に関する情報のうち、警報・注意報など随時発表されるもの)feed_url=jma_feed.FEED_URL_EXTRA_SHORT_TERM# Earthquake/Volcano (地震火山: 地震、火山に関する情報)feed_url=jma_feed.FEED_URL_EQVOL_SHORT_TERM# Others (その他: 上記3種類のいずれにも属さないもの)feed_url=jma_feed.FEED_URL_OTHER_SHORT_TERM# Long-term feed# Regular (定時: 気象に関する情報のうち、天気概況など定時に発表されるもの)feed_url=jma_feed.FEED_URL_REGULAR_LONG_TERM# Extra (随時: 気象に関する情報のうち、警報・注意報など随時発表されるもの)feed_url=jma_feed.FEED_URL_EXTRA_LONG_TERM# Earthquake/Volcano (地震火山: 地震、火山に関する情報)feed_url=jma_feed.FEED_URL_EQVOL_LONG_TERM# Others (その他: 上記3種類のいずれにも属さないもの)feed_url=jma_feed.FEED_URL_OTHER_LONG_TERMfeed=jma_feed.AtomFeed(feed_url)print(feed.id)print(feed.title)print(feed.subtitle)print(feed.updated)print(feed.rights)entries=feed.entriesforentryinentries:print(entry.id)print(entry.title)print(entry.updated)print(entry.author)print(entry.content)print(entry.link)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
io如何从java中的远程FileInputStream中知道扩展名为的文件名   java spring引导不会为JSP返回404,除非编译tomcat maven依赖范围?   ArchUnit:如何避免对java类的依赖冲突   java Hibernate很多都不工作   java tomcat基于表单的身份验证数据源配置错误   java将随机对象声明为私有静态最终属性可以吗?   java Sobel筛选器无法正常工作   我想用java为hangman乘以一个字符串   当我试图运行部署在Tomcat中的任何项目时,ubuntu上的java Tomcat服务器将自动关闭   java更高效地读取按字母顺序排序的文本文件   java Android Studio“尚未附加片段”   在JavaServlet中使用从一种形式到另一种形式的数据的html   检测Java中打开的文件夹(JNativeHook)   jakarta ee Hibernate映射异常:实体映射中的重复列   httpSession在Java中使用什么方法进行会话管理   java如何将两个类的代码外包到一个新的类中,以便两个类都可以调用该方法