Jump to content
Sssascha

Need Help: Website search with 2 arguments

Recommended Posts

Hi folks,

i need your help with a pretty easy workflow i think but i don't get it.

 

I want to search the website dejure.de. If you search for example like for paragraph 433 BGB (german law) the url looks like this: 

http://dejure.org/gesetze/BGB/433'>http://dejure.org/gesetze/BGB/433

I now want to use 2 arguments to search for like 433 BGB so the url in the Alfred workflow would look like 

http://dejure.org/gesetze/"argument 2"/"argument 1"

 but i dont know how to write the script to do that. Unfortunately i have no experience with scripting at all.

 

I would appreciate any help with that.

Edited by Sssascha

Share this post


Link to post

This could be done but not so much with a custom search unless you put the full thing in the custom search. For instance, you could just make a custom search with the url "http://dejure.org/gesetze/{query}" and, using your example, just pass "BGB/433" as the parameter

 

The other way would require using a simple script to read the input and build the url. Wouldn't be hard. How would you prefer to do it?

Share this post


Link to post

The first version with using BGB/433 as query is what i use for now, but i would be "nicer" when i could write 433 BGB like it is natively written. so i would prefer a simple script. i would write it myself if i had a tutorial. :)

Share this post


Link to post

The first version with using BGB/433 as query is what i use for now, but i would be "nicer" when i could write 433 BGB like it is natively written. so i would prefer a simple script. i would write it myself if i had a tutorial. :)

 

If you wanted to do it as a simple shell script you could...


query="{query}"
 
arg1=$(echo $query | cut -d " " -f 1)
arg2=$(echo $query | cut -d " " -f 2)
 
 
open "$url"

That would save whatever you input to the workflow as a variable named query and then create two variables that are the first and second word of the input string saved in $query. Then build the new url variable with the values in their correct place and open that url. This script would be done using a Run Script item. Don't forget to untick the option to Escape Spaces.

Share this post


Link to post

I am trying to do the same thing in Alfred 3 the above workflow didnt work for me. How do i input 2 seperate numbers and trigger this script when I press Enter?

Share this post


Link to post

The above still works in Alfred 3. You're doing something else wrong (possibly you need to change the input to input as {query}).

 

Please post your non-working workflow, so we can see what isn't working and perhaps tell you why.

 

Share this post


Link to post

I would like to second this request. 

I am also trying to build a workflow for the same website, but I have no idea how. 

It would be great if someone could help me with it. 

 

Thank you very much in advance!

Cheiron

Edited by Cheiron

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...