Skip to content

Update daily - Horoscope #671

Update daily - Horoscope

Update daily - Horoscope #671

---
name: "Update daily - Horoscope"
#on: push
on:
schedule:
- cron: "20 1 * * *"
env:
FILE_WEBSITE: website.html
LIST_SIGNES: BELIER TAUREAU GEMEAUX CANCER LION VIERGE BALANCE SCORPION SAGITTAIRE CAPRICORNE VERSEAU POISSONS
jobs:
build_jour:
env:
URL: http://www.astroo.com/horoscope.php
FILE: docs/jour.json
FILE_TMP: docs/jour_tmp.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Website
run: curl -s $URL -o $FILE_WEBSITE
- name: Create JSON
run: |
echo "{" > $FILE_TMP
echo " \"date\": \"$(date +%F)\"," >> $FILE_TMP
for SIGNE in $LIST_SIGNES; do echo " \"${SIGNE,,}\": \"$(cat $FILE_WEBSITE |grep "$SIGNE</a>" |awk -F'</span>' '{ print $2 }' |sed 's/"/\\"/g' |sed 's/\ *$//g')\"," >> $FILE_TMP ; done
sed -i '$ s/.$//' $FILE_TMP
echo "}" >> $FILE_TMP
- name: Recode UTF8
run: |
sudo apt-get update
sudo apt-get -y install recode
cat $FILE_TMP | recode html..utf8 > $FILE
- name: Commit JSON
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add $FILE
git commit -m "Generated $FILE" || true
git pull --rebase
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
build_hebdomadaire:
env:
FILE: docs/hebdomadaire.json
FILE_TMP: docs/hebdomadaire_tmp.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Website
run: |
for SIGNE in $LIST_SIGNES; do curl -s http://www.astroo.com/horoscopes/horoscope_hebdo_${SIGNE,,}.php -o ${SIGNE}.html; done
- name: Extract data
run: |
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 1) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_1 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 2) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_2 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 3) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_3 ; done
sed -i 's/^\ *//g' *CADRAN*
sed -i 's/\"/\\"/g' *CADRAN*
- name: Create JSON
run: |
echo "{" > $FILE_TMP
echo " \"date\": \"$(date +%F)\"," >> $FILE_TMP
for SIGNE in $LIST_SIGNES; do echo " \"${SIGNE,,}\": [\"\", \"$(cat ${SIGNE}_CADRAN_1)\", \"$(cat ${SIGNE}_CADRAN_2)\", \"$(cat ${SIGNE}_CADRAN_3)\" ]," >> $FILE_TMP ; done
sed -i '$ s/.$//' $FILE_TMP
echo "}" >> $FILE_TMP
- name: recode UTF8
run: |
sudo apt-get update
sudo apt-get -y install recode
cat $FILE_TMP | recode html..utf8 > $FILE
- name: Commit JSON
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add $FILE
git commit -m "Generated $FILE" || true
git pull --rebase
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
build_mensuel:
env:
FILE: docs/mensuel.json
FILE_TMP: docs/mensuel_tmp.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Website
run: |
for SIGNE in $LIST_SIGNES; do curl -s http://www.astroo.com/horoscopes/horoscope_du_mois_${SIGNE,,}.php -o ${SIGNE}.html; done
- name: Extract data
run: |
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 1) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_1 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 2) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_2 ; done
for SIGNE in $LIST_SIGNES; do cat ${SIGNE}.html |awk -v RS="</*td>" '/class="hhte" valign="top"/{if (++n == 3) print $0}' |sed 's/<td class="hhte" valign="top">//g' |sed 's/<br>//g' |tr -d '\n' > ${SIGNE}_CADRAN_3 ; done
sed -i 's/^\ *//g' *CADRAN*
sed -i 's/\"/\\"/g' *CADRAN*
- name: Create JSON
run: |
echo "{" > $FILE_TMP
echo " \"date\": \"$(date +%F)\"," >> $FILE_TMP
for SIGNE in $LIST_SIGNES; do echo " \"${SIGNE,,}\": [\"$(cat ${SIGNE}_CADRAN_1)\", \"$(cat ${SIGNE}_CADRAN_2)\", \"$(cat ${SIGNE}_CADRAN_3)\" ]," >> $FILE_TMP ; done
sed -i '$ s/.$//' $FILE_TMP
echo "}" >> $FILE_TMP
- name: recode UTF8
run: |
sudo apt-get update
sudo apt-get -y install recode
cat $FILE_TMP | recode html..utf8 > $FILE
- name: Commit JSON
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add $FILE
git commit -m "Generated $FILE" || true
git pull --rebase
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true