38 lines
1.0 KiB
Bash
38 lines
1.0 KiB
Bash
#!/bin/bash
|
|
# Call with INX Page_num file_name
|
|
function fetch_page() {
|
|
echo "[+] $1/$2"
|
|
curl "https://nsdl.co.in/master_search_res.php" \
|
|
--silent \
|
|
--data cnum=$1 \
|
|
--data "page_no=$2" |
|
|
# for each row
|
|
pup '#nsdl-tables tr json{}' | \
|
|
# generate 6 lines (second column has a link, so parse that) with raw output
|
|
jq --raw-output '.[] | [.children[0].text, .children[1].children[0].text, .children[2].text, .children[3].text,.children[4].text,.children[5].text]|.[]' | \
|
|
# and create a CSV from every 6 lines
|
|
paste -d, - - - - - - | \
|
|
# and we don't need the first row
|
|
tail -n +2 >> "$3"
|
|
}
|
|
function fetch_total_pages() {
|
|
curl "https://nsdl.co.in/master_search_res.php" \
|
|
--silent \
|
|
--data cnum=$1 \
|
|
--data "page_no=1" |
|
|
pup 'input[name=total_page] attr{value}'
|
|
}
|
|
export -f fetch_page
|
|
|
|
function fetch_class() {
|
|
for i in $(seq 1 $2); do
|
|
sem -j 10 --timeout 300% fetch_page $1 $i "$1.csv"
|
|
done
|
|
}
|
|
|
|
for i in A B E F 9; do
|
|
total=$(fetch_total_pages "IN$i")
|
|
fetch_class "IN$i" $total
|
|
done
|
|
|
|
sem --wait |