Page scraping update.
One thing I like to do is page scraping. I can let the computer pull the data I want for me. Unfortunately, if the page is changed, I have to change the code. This happened recently. Since my code is generic enough, the changes were no issue.
There are three scripts. One for love, one for daily, and one for monthly. When I updated the scripts, made them a bit more generic.
Usage:
$ ./horoscope.sh astrologysign
Save to file"
$ ./horoscope.sh astrologysign > savefilename
Daily
Taurus Daily Thursday 3rd December 2015
Your opinions and ideas could be central in a work discussion. The only
'problem' here is that you might seem to be changing your mind. It's
likely that you're not happy with a proposal. Perhaps you feel that the
other party hasn't given due thought to commercial realities. At a quite
different level you could give thought once more to buying a large item.
---------------------------------------------
[code]
####################################
# Horoscope Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="rawcnn.txt"
let "flag = 0"
foo=$1
foo=`echo ${foo:0:1} | tr '[a-z]' '[A-Z]'`${foo:1}
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "http://www.horoscopes.co.uk/$foo/Daily-Horoscope.php" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
# where to start
echo $line | grep -q "$foo Daily"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
# where to end
echo $line | grep -q "Yesterday's Horoscope"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "IMG"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
Love
Taurus Love Friday 27th November 2015
It's arguably time to go back over friendships that have developed within
the last two years. There may be people you need to catch up with. It
might also be the case that this isn't going to happen 'naturally' and
that some effort (travel) will be required. Where romance is concerned,
you'd perhaps prefer to invite someone into your lair - or at least to
feel that you're meeting in a place that's familiar. With those born under
Gemini, Libra, Sagittarius and Aquarius capturing your attention (and
perhaps because you're interested in what's happening in their love
lives), the next seven days could be full of talk and plans. During this
period too someone already very close may be ready to tell you what
they've been thinking and feeling for the last month - and describe the
help they think they need to rebalance their emotions.
---------------------------------------------
taurus
[code]
####################################
# Horoscope Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="rawcnn.txt"
let "flag = 0"
# end assignments
#=================================
#
# Get data file
#---------------------------------
#end=$(echo $1 | tr '[:lower:]' '[:upper:]')
foo=$1
foo=`echo ${foo:0:1} | tr '[a-z]' '[A-Z]'`${foo:1}
end="ARIES"
elinks -dump "http://www.horoscopes.co.uk/$foo/Love-Horoscope.php" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "$foo Love"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q $end
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "TAURUS"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo $1
#===================================
# End.
####################################
[/code]
Monthly
Taurus Monthly December 2015
Mars continues to travel through Venus ruled Libra this month whilst from
5th, Venus moves through your opposite sign of Scorpio. The combination
provides what is known as 'mutual reception'. From the financial
perspective, you could gain considerably around Sunday 6th. Between 6th
and the New Moon on 11th, a breakthrough could be reached. In fact, in the
hours before the New Moon and determined not to squander any bonus, you
might decide to take time out and consider an investment strategy for
2016. A strong possibility is that a project you viewed as being a second
string to your bow, will gather a life of its own. Initially however you
may need to make some kind of investment. That could be done between 14th
and 19th. It's actually over the festival period itself between 24th and
28th, that you may be particularly excited about developing opportunities.
What might also be apparent to you, is that an investment in home
improvement in 2016 would be wise.If you would like to learn more about
planet cycles and global finances, please sign up the free newsletter
Click Here for Details
---------------------------------------------
[code]
####################################
# Horoscope Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="rawcnn.txt"
let "flag = 0"
foo=$1
foo=`echo ${foo:0:1} | tr '[a-z]' '[A-Z]'`${foo:1}
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "http://www.horoscopes.co.uk/$foo/Monthly-Horoscope.php" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "$foo Monthly"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q "ARIES"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "IMG"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
There are three scripts. One for love, one for daily, and one for monthly. When I updated the scripts, made them a bit more generic.
Usage:
$ ./horoscope.sh astrologysign
Save to file"
$ ./horoscope.sh astrologysign > savefilename
Daily
Taurus Daily Thursday 3rd December 2015
Your opinions and ideas could be central in a work discussion. The only
'problem' here is that you might seem to be changing your mind. It's
likely that you're not happy with a proposal. Perhaps you feel that the
other party hasn't given due thought to commercial realities. At a quite
different level you could give thought once more to buying a large item.
---------------------------------------------
[code]
####################################
# Horoscope Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="rawcnn.txt"
let "flag = 0"
foo=$1
foo=`echo ${foo:0:1} | tr '[a-z]' '[A-Z]'`${foo:1}
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "http://www.horoscopes.co.uk/$foo/Daily-Horoscope.php" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
# where to start
echo $line | grep -q "$foo Daily"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
# where to end
echo $line | grep -q "Yesterday's Horoscope"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "IMG"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
Love
Taurus Love Friday 27th November 2015
It's arguably time to go back over friendships that have developed within
the last two years. There may be people you need to catch up with. It
might also be the case that this isn't going to happen 'naturally' and
that some effort (travel) will be required. Where romance is concerned,
you'd perhaps prefer to invite someone into your lair - or at least to
feel that you're meeting in a place that's familiar. With those born under
Gemini, Libra, Sagittarius and Aquarius capturing your attention (and
perhaps because you're interested in what's happening in their love
lives), the next seven days could be full of talk and plans. During this
period too someone already very close may be ready to tell you what
they've been thinking and feeling for the last month - and describe the
help they think they need to rebalance their emotions.
---------------------------------------------
taurus
[code]
####################################
# Horoscope Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="rawcnn.txt"
let "flag = 0"
# end assignments
#=================================
#
# Get data file
#---------------------------------
#end=$(echo $1 | tr '[:lower:]' '[:upper:]')
foo=$1
foo=`echo ${foo:0:1} | tr '[a-z]' '[A-Z]'`${foo:1}
end="ARIES"
elinks -dump "http://www.horoscopes.co.uk/$foo/Love-Horoscope.php" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "$foo Love"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q $end
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "TAURUS"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo $1
#===================================
# End.
####################################
[/code]
Monthly
Taurus Monthly December 2015
Mars continues to travel through Venus ruled Libra this month whilst from
5th, Venus moves through your opposite sign of Scorpio. The combination
provides what is known as 'mutual reception'. From the financial
perspective, you could gain considerably around Sunday 6th. Between 6th
and the New Moon on 11th, a breakthrough could be reached. In fact, in the
hours before the New Moon and determined not to squander any bonus, you
might decide to take time out and consider an investment strategy for
2016. A strong possibility is that a project you viewed as being a second
string to your bow, will gather a life of its own. Initially however you
may need to make some kind of investment. That could be done between 14th
and 19th. It's actually over the festival period itself between 24th and
28th, that you may be particularly excited about developing opportunities.
What might also be apparent to you, is that an investment in home
improvement in 2016 would be wise.If you would like to learn more about
planet cycles and global finances, please sign up the free newsletter
Click Here for Details
---------------------------------------------
[code]
####################################
# Horoscope Grabber
#
#===============================
# Assignments
# --------------------------------
datafile="rawcnn.txt"
let "flag = 0"
foo=$1
foo=`echo ${foo:0:1} | tr '[a-z]' '[A-Z]'`${foo:1}
# end assignments
#=================================
#
# Get data file
#---------------------------------
elinks -dump "http://www.horoscopes.co.uk/$foo/Monthly-Horoscope.php" > $datafile
#=================================
#
# Extract and display data
#---------------------------------
while read line
do fdata[$a]=$line
echo $line | grep -q "$foo Monthly"
if [ $? -eq 0 ]; then
# header
clear
let "flag = 1"
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q "ARIES"
if [ $? -eq 0 ]; then
let "flag = 0"
else
echo $line | grep -q "IMG"
if [ $? -eq 0 ]; then
let "response = donothing"
else
echo $line | sed 's/\[.*\]//'
fi
fi
fi
let "a += 1"
done < $datafile
# footer
echo ---------------------------------------------
echo
#===================================
# End.
####################################
[/code]
Comments
Post a Comment