Skip to content

Instantly share code, notes, and snippets.

@Steven-Chan
Last active June 25, 2018 09:06
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 Steven-Chan/f9fb3ce5796f1cb3df00ad0838ba22ea to your computer and use it in GitHub Desktop.
Save Steven-Chan/f9fb3ce5796f1cb3df00ad0838ba22ea to your computer and use it in GitHub Desktop.
Goodnuts.hk scrapper
#!/bin/bash
# usage:
# ./goodnuts-scrapper.sh 星期一
# ./goodnuts-scrapper.sh 星期二
day=$1
wget -q http://goodnuts.hk/ -O - \
| tr '\n' ' ' \
| perl -nle "print $& if m{<tr> <th>$day</th>.*?</tr>}" \
| perl -pe 's/(<\/th>|<\/tr>|<\/td>|<th>|<tr>|<td>)/\n/g' \
| sed -n 3,9p \
| sed '/^ $/d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment