Jump to content
Benzi

Wikipedia workflow (alternate)

Recommended Posts

Quite a simple workflow to search articles on wikipedia (English version). Inspired by a similar workflow here, but it appears the download link is broken...

 

titles.png

 

Based on feedback from folks, I have an updated version of this workflow. It allows you to

  • Search against regional Wikipedia sites. E.g. to search against German wikipedia, type "w de what to search for"
  • i.e. "w <language code> <search term>"
  • Language codes are from Wikipedia.
  • You can also configure it to search against just one default Wikipedia by modifying the script filter as mentioned in the workflow.
  • Against each result, a snippet of the text from the wiki page is displayed

Remember, you can press the Shift key against a search result to quickly view the associated web page from within Alfred.

 

Try the new version and let me know your comments.

 

 

Q: How can I set one language as the default?

 

Open the workflow's Script Filter in Alfred, and follow the steps mentioned in there.

Edited by Benzi

Share this post


Link to post

thats great. thanks a lot.

which lines do i have to change to work with german wikipedia?

only in the w.py replace the "en.wiki" with "de.wiki" does't work well. search yes, open safari wiki website no.  :(

thanks again..

Share this post


Link to post

Could you please try downloading and installing the workflow again? This will overwrite your changes so you need to change "en.wiki" back to to "de.wiki" again. Please try searching again and see if it works.

 

If its still not working, let me know if possible what you are searching for and I will try to check at my end. There was a small issue (maybe related to what you reported) with the script which was fixed.

 

Thanks!

Share this post


Link to post

wow.. thats was fast.  ;)  thanks.

changed all the en.wiki to de.wiki in the w.py file.

 

now safari and the de. wiki websites opens.

but searching for i.e. frankfurt oder frankfurt am main doesn't show a result in alfred.

also with names like "dirk" "dirk bach"

 

thanks for you passionate work and sharing.

Share this post


Link to post

Thank you very much!

 

I would like to use this for english and german wikipedia, so I put both in. You can chose by typing "wiki en" or "wiki de". Have fun, germans: http://d.pr/f/LS3q

I was just about to try and implement the same thing for Hebrew, glad someone already did the hard work for me  :P .

Oddly enough, I can't get it to work in Hebrew though, I presume it has something to do with the script's encoding, which I wasn't able to change to UTF-8 for some reason and still have the script working.

Would be more than glad if someone could look into this and maybe help me solve this :).

Share this post


Link to post

I was just about to try and implement the same thing for Hebrew, glad someone already did the hard work for me  :P .

Oddly enough, I can't get it to work in Hebrew though, I presume it has something to do with the script's encoding, which I wasn't able to change to UTF-8 for some reason and still have the script working.

Would be more than glad if someone could look into this and maybe help me solve this :).

Well, I think the encoding is part of the problems I face with the de.wikipedia-API. Some words like "Müller" doesn't seem to work properly with this workflow. I couldn't solve this by now and I haven't got the greatest knowledge about python (honestly: I have kind of no knowledge about python ;) ).

Maybe someone else could help us?

Share this post


Link to post

Well... I am not very strong with Python either ;), but the issue was to do with Unicode encoding. So words like "Müller" were failing. I have updated my original workflow with some modifications and is available in the original download link.

 

Since many have modified the workflow, the code change was done in w.py file, a snippet is below

 

 

def resultParse(item):    
    item_arg = u'http://en.wikipedia.org/wiki/' + urllib.quote(item['title'].encode("utf8"))
    return {
        'uid': "." + item['title'],
        'arg': item_arg,
        'title': item['title'],
        'subtitle': 'Read article on ' + item['title'],
        'icon': 'icon.png',
    }
 

As you can see, its against the English version of Wikipedia. Please check and let me know if this is of any use. 

 

Anyways, got to read about http://en.wikipedia.org/wiki/Hermann_Müller_(botanist)  :)

Share this post


Link to post

nice work~

I change "en.wiki" to "zh.wiki" doesn't work. Can you give me some help?

Thx a lot.

 

Hi there,

Can you try downloading the latest workflow from my original download link?

 

After that, you need to change en.wiki to zh.wiki in two places in w.py.

 

 

in search_for()
    rt_api = "http://zh.wikipedia.org/w/api.php"

in resultParse()
    item_arg = u'http://zh.wikipedia.org/wiki/' + urllib.quote(item['title'].encode("utf8"))
    

 

I tried that and looked up http://zh.wikipedia.org/wiki/香港最高電影票房收入列表 (well to be honest, I just typed in some Chinese characters and that was one of the search results... I have no clue what that page is about  :) )

Share this post


Link to post

Hi there,

Can you try downloading the latest workflow from my original download link?

 

After that, you need to change en.wiki to zh.wiki in two places in w.py.

 

 

in search_for()
    rt_api = "http://zh.wikipedia.org/w/api.php"

in resultParse()
    item_arg = u'http://zh.wikipedia.org/wiki/' + urllib.quote(item['title'].encode("utf8"))
    

 

I tried that and looked up http://zh.wikipedia.org/wiki/香港最高電影票房收入列表 (well to be honest, I just typed in some Chinese characters and that was one of the search results... I have no clue what that page is about  :) )

Thanks for the change.

I combined both versions into this. Basically allows "w en <query>" for English Wikipedia and "w he <query>" for Hebrew Wikipedia.

You can easily change and duplicate for more languages, just look at the w_he.py file in the workflow and replace every occurrence of "he" with your language's shortened term.

 

Also, I'm sure the main script by Benzi can be changed like so that it'll accept another parameter for language, but I too lazy to change it  ^_^ .

Basically you'll need to add another parameter for both the search_for and the resultParse functions, that'll be the language, than parse the query into the first word (which'll be the language), and the rest, which'll be the rest of the query (the actual query that'll be passed on to Wikipedia to be searched for).

Share this post


Link to post

I've created a duplicate of the Script Filter node for each language I want  to search to avoid typing the 'en' for default searches, it works amazingly!

Share this post


Link to post

Hi all, thanks to all your feedback,  I have created a new version put up here, with slightly better support for multi language search.  See the first post in this topic for details and try it out.

 

Hi Benzi,

 

I just installed your workflow. It doesn't matter what language I choose, all the results I see are from 'en.wikipedia.org.' (Tried with 'es' and 'it', btw). How can I fix this? (I installed the latest version you uploaded).

Share this post


Link to post

Hi, is it possible that this workflow ignores two word search terms in that it only takes the first term. For example when you search for people by first name and last name, it does not seem to matter what the last name is. Anyone else seeing this?

Share this post


Link to post

Hi, is it possible that this workflow ignores two word search terms in that it only takes the first term. For example when you search for people by first name and last name, it does not seem to matter what the last name is. Anyone else seeing this?

That's right, but you can easily work around that by typing a + or - instead of a blank. Instead of "George Washington" just type "George+Washington".

Share this post


Link to post

Hi, is it possible that this workflow ignores two word search terms in that it only takes the first term. For example when you search for people by first name and last name, it does not seem to matter what the last name is. Anyone else seeing this?

 

 

That's right, but you can easily work around that by typing a + or - instead of a blank. Instead of "George Washington" just type "George+Washington".

 

 

For the two word issue, can you please downloading the version again? I noticed this myself a bit late, but I hope this is now fixed.

 

If you have en setup as default, searching for "muller thomas" should bring up "Thomas Müller" as follows

 

twowords.png

Share this post


Link to post

For the two word issue, can you please downloading the version again? I noticed this myself a bit late, but I hope this is now fixed.

 

If you have en setup as default, searching for "muller thomas" should bring up "Thomas Müller" as follows

The new version works perfectly, tried both English and Hebrew. Thanks :).

Edited by The_Ben

Share this post


Link to post

Thank you very much! It's amazing how easily this can be used to search in other wikis, too. I copied and changed the workflow to search wiktionary.org. Works like a charm!

Share this post


Link to post

The new version works perfectly. I basically use it to replace alfred's standard wikipedia search. Instead of using it as multi-language, I have installed it several times, each with a fixed language so that keywords wiki (for english), wikifr, wikiar each give me the corresponding wikipedia search option (this could, of course, also all be put in one workflow..... Thanks very much

Share this post


Link to post

Hi Benzi,

 

I just installed your workflow. It doesn't matter what language I choose, all the results I see are from 'en.wikipedia.org.' (Tried with 'es' and 'it', btw). How can I fix this? (I installed the latest version you uploaded).

 

*bump*

 

Downloaded and reinstalled again, but keep having the same problem. Any ideas on how to fix it?

Share this post


Link to post

*bump*

 

Downloaded and reinstalled again, but keep having the same problem. Any ideas on how to fix it?

 

Sorry, I think I missed to see your original post.

 

Just to check, did you download the updated version (there are two download links in the original post) - the updated one is here (The extension name is Wikipedia ML).

Share this post


Link to post

Sorry, I think I missed to see your original post.

 

Just to check, did you download the updated version (there are two download links in the original post) - the updated one is here (The extension name is Wikipedia ML).

 

Yes, that's exactly the one I reinstalled, your updated version.

 

ETA: Is there anything else I need to delete besides the workflow before reinstalling? Not sure if I followed all the steps in the reinstall.

Edited by Southgirl

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×