英国铁路行业使用的收集铁路代码的小型刮网机
pyrcs的Python项目详细描述
pyrcs
一种小型的网络刮板,用于收集英国铁路行业使用的铁路代码和其他数据。
安装
pip install --upgrade pyrcs
注释:
确保安装了最新版本的
pip
。python -m pip install --upgrade pip
Python-Levenshtein
,此软件包的依赖项之一,可能无法安装在没有VC2015(或更高版本)的Windows操作系统上。解决方法是下载并安装其.whl文件。在这种情况下,如果在64位操作系统上使用python 3.7,则应该选择python_Levenshtein-0.12.0-cp37-cp37m-win_amd64.whl
。pip install --upgrade \path\to\python_Levenshtein-0.12.0-cp37-cp37m-win_amd64.whl
快速入门(示例)
The following examples may provide a quick guide to the usage of the package.
1. CRS, NLC, TIPLOC and STANOX Codes
If your preferred import style is ^{
If your preferred import style is ^{
After importing the module, you can create a 'class' for the location codes (including all CRS, NLC, TIPLOC, STANME and STANOX) :
^{pr 6}$Given different preferences, there are several alternative ways of importing the module.
Alternative 1:
^{pr 7}$Alternative 2 (Preferred and used for the following examples):
^{pr 8}$1.1 Locations beginning with a given letter
You can get the location codes starting with a specific letter, say 'A' or 'a', by using the method^{
The keys of ^{
- ^{
} - ^{
} - ^{
}
The corresponding values are:
- ^{
} is a ^{ } that contains the table data. You may compare it with the table on the web page: http://www.railwaycodes.org.uk/crs/CRSa.shtm location_codes_a['Last_updated_date']
是上次更新网页的日期(在str
)location_codes_a['Additional_note']
是网页上的一些重要附加信息(如果有的话)
1.2此类别中所有可用的位置代码
You can also get all available location codes in this category as a whole , using the method ^{
The keys of ^{
- ^{
} - ^{
} - ^{
} - ^{
}
The corresponding values are:
- ^{
} is a ^{ } that contains all table data (from 'A' to 'Z') - ^{
} is the latest 'Last_updated_date' (in ^{ }) among all initial-specific table data - ^{
} is some important additional information on the web page (if available) - ^{
} is a ^{ } for Other systems
2.工程师线路参考(ELR)
^{pr 11}$2.1 ELR codes
To get ELR codes starting with a specific letter, say ^{
The keys of ^{
- ^{
} - ^{
}
The corresponding values are:
- ^{
} is a ^{ } that contains the table data. You may compare it with the table on the web page: http://www.railwaycodes.org.uk/elrs/elra.shtm elr_a['Last_updated_date']
是上次更新网页的日期(在str
)
要获取所有可用的elr代码,请使用方法fetch_elr
,该方法返回dict
:
elr_codes=em.fetch_elr()
elr_codes
的键包括:
'ELRs_mileages'
'Latest_updated_date'
相应的值为:
elr_codes['ELRs_mileages']
是包含所有表数据(从'a'到'z')elr_codes['Latest_updated_date']
是所有初始特定表数据中最新的“最后更新日期”(instr
)
2.2里程文件
To collect more detailed mileage data for a given ELR, say ^{
The keys of ^{
- ^{
} - ^{
} - ^{
} - ^{
}
The corresponding values are:
- ^{
} is the name (in ^{ }) of the given ELR - ^{
} is associated line name (in ^{ }) - ^{
} is associated sub line name (in ^{ }), if available - ^{
} is a ^{ } of the mileage file data
3. Railway stations data
The data of railway stations belongs to another category, 'Other assets'
frompyrcs.other_assetsimportOtherAssetsother_assets_cls=OtherAssets()
与获取上述“CRS、NLC、TIPLOC和STANOX代码”类似,通过给定的首字母(例如“A”)获取站点数据:
stations_a=other_assets_cls.Stations.collect_station_locations('A')
要获取所有可用的电台数据:
stations=other_assets_cls.Stations.fetch_station_locations()
stations_a
和stations
的数据类型都是dict
。