2
위키 트래 벌 API를 통해 XML 파일이 제공된다는 사실을 알게되었습니다. 예 : http://wikitravel.org/en/Special:Export/San_FranciscoWikitravel XML 트리 구조
특정 제목 (예 : 이해, 들어가기, 돌아 다니기)이있는 나무를 구할 방법이 있습니까?
위키 트래 벌 API를 통해 XML 파일이 제공된다는 사실을 알게되었습니다. 예 : http://wikitravel.org/en/Special:Export/San_FranciscoWikitravel XML 트리 구조
특정 제목 (예 : 이해, 들어가기, 돌아 다니기)이있는 나무를 구할 방법이 있습니까?
MediaWiki API의 action=parse
을 사용하면됩니다.
예를 들어, 쿼리 http://wikitravel.org/wiki/en/api.php?format=xml&action=parse&prop=sections&page=San%20Francisco 같은 것을 반환합니다이에서
<api>
<parse>
<sections>
<s toclevel="1" level="2" line="Districts" number="1" index="1" fromtitle="San_Francisco" byteoffset="1186" anchor="Districts"/>
<s toclevel="1" level="2" line="Understand" number="2" index="2" fromtitle="San_Francisco" byteoffset="9563" anchor="Understand"/>
<s toclevel="2" level="3" line="History" number="2.1" index="3" fromtitle="San_Francisco" byteoffset="9578" anchor="History"/>
<s toclevel="2" level="3" line="Climate" number="2.2" index="4" fromtitle="San_Francisco" byteoffset="13913" anchor="Climate"/>
<s toclevel="2" level="3" line="Literature" number="2.3" index="5" fromtitle="San_Francisco" byteoffset="16502" anchor="Literature"/>
<s toclevel="2" level="3" line="Movies" number="2.4" index="6" fromtitle="San_Francisco" byteoffset="19404" anchor="Movies"/>
<s toclevel="2" level="3" line="Tourist information" number="2.5" index="7" fromtitle="San_Francisco" byteoffset="23236" anchor="Tourist_information"/>
<s toclevel="1" level="2" line="Talk" number="3" index="8" fromtitle="San_Francisco" byteoffset="24227" anchor="Talk"/>
…
</sections>
</parse>
</api>
을, 당신은 섹션 트리를 재구성 할 수 있습니다.
모든 제목이 분리되어 있지만 해당 섹션에 포함 된 정보를 포함하도록 확장되지는 않습니다. 이 방법과 확장 된 트리를 모두 얻을 수있는 방법이 있습니까? 감사! – 7ch5
'prop = sections | wikitext'를 사용하여 원본 텍스트를 얻을 수도 있습니다. 텍스트는 섹션으로 나뉘 지 않지만,'byteoffset's를 사용할 수 있어야합니다. – svick
매력처럼 작동합니다. 감사! – 7ch5