1#!/usr/bin/bash
2
3url=http://physics.nist.gov/cgi-bin/ffast/ffast.pl
4
5if [ -z "$1" ]
6then
7  echo "what material are you trying to get data for? please supply atomic number."
8  echo "usage: get_xray_db_data ATOMNO [output file]"
9fi
10
11Z=$1
12
13range=S
14
15modifiers="?Z=$Z&Formula=&gtype=4&range=$range&lower=0&upper=500&density=&frames=noframes"
16
17tfile=`mktemp --tmpdir get_xray.XXX`
18
19echo $tfile
20
21wget "$url$modifiers" -O $tfile;
22#extract element name from Z
23element_symbol=`w3m -T text/html -dump $tfile |head -c 2`
24echo writing output to $element_symbol.txt
25
26w3m -T text/html -dump $tfile |sed '{1,100 s/^[^0-9\n]/#&/}' |sed '{s/^$/#/}' >$element_symbol.txt
27
28rm $tfile
29