A (quick and dirty) script to look up companies by their code on argaam.

This script is useful for when, for example, you want to know the value of a portfolio at a certain point in time. In this case, you need to look up prices of a list of companies.

./currl 1140 2222 ..etc 

Here is the script.

#!/bin/bash

# A script to look up companies by their code on argaam 
#
# USAGE
#
# first, open the terminal and navigate to the file folder and make sure the script is executable on your computer with
#
# chmod +x currl
#
# open the GUI version of firefox, and make sure terminal version is installed on your computer
# then, for the companies you want to look up
#
# ./currl 1140 2222 ...
# 
# NOTES
#
# Sometimes it gets the address half right. In that case, delete the first half.
#
# -- Abdulaziz - July, 2021

for k in $@; do
	payload="search=$k&langID=1&markedID=3&userID=&sessionID=" 
	echo Executing curl command for $k
	curl -d  $payload https://search.argaam.com/search > output
	link=$(cat output | grep -m 1 "row clearfix feedbacker" | sed 's/.*data-href="\(.*\)">/\1/')
	full_link="https://www.argaam.com$link"
	firefox $full_link
done