Pull out specific parts of text in Alfred - alfred

I am trying to make a simple tool that takes an Amazon URL and outputs the product ID.
As an example the following UL has a product ID of B003VAHYTG. https://smile.amazon.com/Logitech-Multimedia-Speaker-System-Z533/dp/B011O613W2?ref_=ast_sto_dp&th=1&psc=1
How can I create a workflow that takes the URL as input and cuts out the ID? I could write a python script to do it, but it seems like it would be a built in feature of Alfred. Any thoughts? Am I just overlooking an obvious solution?

Related

How to read/search specific content in a webpage using shell scripting

I'm a beginner in shell scripting.
I'm trying to write a script in which a part of it involves reading the value from a webpage. In this case, The shell script tries to fetch the IMDB rating of a movie by going to the movie's IMDB page.
Can someone suggest me how i can achieve this & also what are the topics i need to learn ?
Thank you.
You can use wget and curl to get the page. Then you'll need to use regex or some other string manipulation to get the information you need from that. It would be a lot easier to use a library to do some of these things for you.

automatic copy paste from Browser to Microsoft Word

I want to copy some specific texts from internet browser(chrome) and want to paste them in proper fields of Microsoft word.. Let me explain what I want exactly... I have this kind of page structure in chrome-
Name-Deepak,Raju,Jhon,Robert.......
Salary-200,254,673,953...
Phone-987535747,856889479,64688539,357954228....
Etc..
I have a table in MS word as-
Sl. Phone. Name. Salary.
Can I make a auto copy paste program to make my table-
Sl. Phone. Name. Salary
1. 987535747. Deepak. 200
2. .......
Like this? Suggest me the best suitable platform to compile this.. Its best for me, if a bat file can do the job.. I know bit odd question.. And I should not ask the entire program,rather a section of it..Bt still....... actually I don't know from where to start..
Rather than use a wget which will only retrieve the document, what you want is a way of parsing the results of the web content and writing into an output file.
After searching the web, I could only come across
lynx which
is a text based browser and you can parse the -dump parameter to
output the text into file which you can then write a script to do
the final bit.
Also take a look at this
link
for more info on switches you can use most especially if the desired
text has links in it (-nolist)
elinks which is an advanced text based browser

RoboHelp CSH always goes to the first help page

I have a WebHelp content directory created using RoboHelp 9. From a web application, I'm trying to display a specific help page using their CSH JavaScript API:
RH_ShowHelp(0, "WebHelp/index.htm>MainWindow", HH_HELP_CONTEXT, <some map id>);
The problem is, the resultant popup always displays the first help topic, regardless of the map id I pass. Does the map file that was created for the RoboHelp project need to be included somewhere in the resultant WebHelp directory? I would think that RoboHelp would handle including whatever it needed in the generated content.
I think what's more likely is that I messed up somewhere in generating the map file/ids. To generate the map ids, I did the following:
Created a new map file
Double clicked it to open the map file window
Selected everything from the right list block (all the topics and help sections)
Clicked 'Auto Generate'
Are there further steps I need to follow before CSH will work?
Perhaps you forgot to include your mapfile in the generated output.
This is done in Web Help, under Content Categories.
Then, you can specify the topic number in the last argument to RH_ShowHelp.
Are you using the published output (not the generated output) in your content directory?
If that doesn't help, you can use simple links like this, which open the specified topic in help in the Help framework:
http://example.com/WebHelp/index.htm#someSubfolderThatIsAChildOfTheRootHelpFolder/theTopicYouWant.htm

How to make the cities/countries dropdown like facebook does?

See the screenshot here:
I'd like the user to just type a city or country name and the autocompleter will show suggested items.
How should I start for creating it?
Are there any API(s) or web services for me to call?
Where can I find the database of all cities/countries in the world?
I think this would be the best database for your situation, check it out:
http://www.geodatasource.com/cities-free.html
You first need a autocomplete plugin.
I recommend to use the jQuery-Ui Auto Complete Plugin.
The database could as example be this, but eventually try to search a bit for yourself.
There was already a question on stackoverflow about a database for cities of the world.
A simple text file with all cities may also be this.
There are very much of those libraries, but you have to chose the right one for you.
My solution may not be the best, but it's a starting point:
Google a list with all countries (ISO-Standard), paste it into a txt-file. Then you can simply read that file with PHP an create a select menu with the contents of the file.
It does not incorporate the cities, but maybe it helps you in some way.

Ruby XML Parsing with Nokogiri/XPath

I have a shopify store that I want to automatically update the product variants inventory levels with, using a live xml feed from the wholesaler I use.
I'm learning to program (Ruby) and this is my first project, but after researching here is how I think it should work.
Use Ruby/Nokugiri to parse the XML feed from the wholesaler, and then Xpath to locate both the unique product variant SKU code, and the stock level.
Somehow I need to use this SKU to refer back to my Shopify store product XML list, and pull out the variants unique ID using the SKU code.
Then use something like the builder gem to build the XML format that shopify needs, and then use curl to PUT the changes. I'm guessing I loop this process for every product?
I know Shopify only has a 300 call limit, so I've got the article on putting a delay in the script, but I get the feeling the above method isn't the easiest way to go about this?
With Shopify you need to apply the variant stock level update against unique variant xml files, so I need to build the unique xml file/code and PUT it against /admin/variants/#[thevariantid].xml
I'm looking forward to trying to put this together and learning in the process, but am I on the right track with this? Are there simpler gems I should be looking at?
n.b I've only recently started learning Ruby, and will head to Rails afterwards. I know a bit about XML and it's structure so should be ok finding what I need with XPath.
You’re on the right track, but I’d use the shopify_api gem to do the talking to Shopify instead of having to form the XML and URIs yourself: https://github.com/Shopify/shopify_api
There’s an article on our wiki that might also help you out with regards to the API call limit but just let me know if you need more space – we’re pretty flexible and the limit is really just there to keep scripts from going wild and affecting service for everyone else.
Your proposed path seems good, except that there's no need to use the 'builder' gem, as Nokogiri has some very nice XML-building built into it.

Resources