我想解析维基百科电厂列表,其中包含{{Location map}}模板。在我的例子中,我使用德语翻译,但这不应该改变基本过程。
如何从这些代码中取出label =,lat =,lon =和region =参数? 对于像BeautifulSoup这样的html解析器,这可能不算什么,而是awk?
{{ Positionskarte+
| Tadschikistan
| maptype = relief
| width = 600
| float = right
| caption =
| places =
{{ Positionskarte~
| Tadschikistan
| label = <small>[[Talsperre Baipasa|Baipasa]]</small>
| marktarget =
| mark = Blue pog.svg
| position = right
| lat = 38.267584
| long = 69.123906
| region = TJ
| background = #FEFEE9
}}
{{ Positionskarte~
| Tadschikistan
| label = <small>[[Kraftwerk Duschanbe|Duschanbe]]</small>
| marktarget =
| mark = Red pog.svg
| position = left
| lat = 38.5565
| long = 68.776
| region = TJ
| background = #FEFEE9
}}
...
}}
提前致谢!
答案 0 :(得分:1)
只需使用正则表达式提取信息。
例如像这样(<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:foreground="?attr/selectableItemBackground"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/images_list_view"
android:clipToPadding="false"
android:src="@drawable/user">
</ImageView>
</android.support.v7.widget.CardView>
)
PHP