Skip to content

Instantly share code, notes, and snippets.

Created September 23, 2012 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3769651 to your computer and use it in GitHub Desktop.
Save anonymous/3769651 to your computer and use it in GitHub Desktop.
nix.ru HDD/SSD parsing
#!/bin/sh
now=`date +"%m_%d_%Y"`
wget --referer="http://www.something.com" --user-agent="your_useragent" -dnv http://www.nix.ru/price/price_list.html?section=hdd_all --output-document="./hdd/$now.html"
wget --referer="http://www.something.com" --user-agent="your_useragent" -dnv http://www.nix.ru/price/price_list.html?section=ssd_all --output-document="./ssd/$now.html"
cat ./hdd/$now.html | grep -Eo "<td class='tac d'><a class='p' href='javascript:void\(InsPosFast\([0-9]*,[0-9]*,null,1\)\)' title='.*</a></td>" | cut -d">" -f3 | cut -d"<" -f1 | cut -d" " -f1,2 --output-delimiter="A" | sed 's/A//' > ./parse_price.txt
gawk '{s+=$1} END {print s}' ./parse_price.txt > ./parse_sumprice.txt
cat ./hdd/$now.html | grep -Eo "<td id='sn_.*" | cut -d">" -f2 | cut -d"<" -f1 | sed 's/ \xD2\xE1/ 1000/' | sed 's/ \xC3\xE1/ 1/' > ./parse_size.txt
gawk '{s+=$1*$2} END {print s}' ./parse_size.txt > ./parse_sumsize.txt
paste -d" " ./parse_sumprice.txt ./parse_sumsize.txt > parse_all.txt
gawk '{s=$1/$2} END {print "$now\t"s}' ./parse_all.txt >> hdd.txt
cat ./ssd/$now.html | grep -Eo "<td class='tac d'><a class='p' href='javascript:void\(InsPosFast\([0-9]*,[0-9]*,null,1\)\)' title='.*</a></td>" | cut -d">" -f3 | cut -d"<" -f1 | cut -d" " -f1,2 --output-delimiter="A" | sed 's/A//' > ./parse_price.txt
gawk '{s+=$1} END {print s}' ./parse_price.txt > ./parse_sumprice.txt
cat ./ssd/$now.html | grep -Eo "<td id='sn_.*" | cut -d">" -f2 | cut -d"<" -f1 | sed 's/ \xD2\xE1/ 1000/' | sed 's/ \xC3\xE1/ 1/' > ./parse_size.txt
gawk '{s+=$1*$2} END {print s}' ./parse_size.txt > ./parse_sumsize.txt
paste -d" " ./parse_sumprice.txt ./parse_sumsize.txt > parse_all.txt
gawk '{s=$1/$2} END {print "$now\t"s}' ./parse_all.txt >> ssd.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment