Как я могу получить доступ к Википедии в автономном режиме из командной строки?

763
Rory A Campbell

Я хочу открыть офлайновую версию википедии из командной строки с указанной статьей (и желательно с размером окна и позицией).

Я скачал дампы из Википедии в нескольких различных форматах, включая xml, обычный текст и zim. Я не могу понять, как получить доступ к XML или обычному тексту полезным способом. Я могу просмотреть zim-файл, используя kiwix, но не могу получить доступ к определенной статье из командной строки.

Кто-нибудь знает, как можно открыть указанную статью, используя командную строку? Я использую MacBook, если это имеет какое-либо значение. Спасибо

1
в этом контексте под оффлайн вы подразумеваете не подключенный к интернету? так у вас есть файл, загруженный локально? 10 лет назад 0

1 ответ на вопрос

1
8bittree

You can use kiwix as a server to host a zim file and then open up pages in a web browser. The open command on Mac OS X will let you specify the page from the command line.

Assuming you have kiwix installed in /Applications, you can use this command to start up the kiwix-server on port 8000:

/Applications/Kiwix.app/Contents/Resources/bin/kiwix-serve path/to/wikipedia.zim --port=8000 & 

Then you can access your Wikipedia dump with

open http://127.0.0.1:8000/ 

I'm not sure of anyway of making a dump of the all the urls in the zim file, but any that you find either manually, or by figuring out a dump method should be usable with open. I made a small book with Wikipedia book creator and downloaded it as a zim file. Commands like the following worked fine for me:

open http://127.0.0.1:8000/Some_Code_Languages/A/Python%20%28programming%20language%29 

Also, don't forget to stop the kiwix-server process when you're done and before you close your terminal. Use the fg command to bring it to the foreground and <Ctrl>-c to stop it. Alternatively hunt it down in Activity Monitor.