fetch.sh 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. unset CDPATH
  3. bin=`dirname "$0"`
  4. bin=`cd "$bin"; pwd`
  5. cygwin=false
  6. case "`uname`" in
  7. CYGWIN*) cygwin=true;;
  8. esac
  9. APP_HOME=$bin
  10. # some Java parameters
  11. PYTHON=`which python 2>/dev/null`
  12. if [[ $PY_HOME != "" ]]; then
  13. PYTHON=$PY_HOME/bin/python
  14. fi
  15. if test -z "$PYTHON"; then
  16. echo "No python found in the PATH. Please install Python and set PY_HOME."
  17. exit 1
  18. fi
  19. # restore ordinary behaviour
  20. # unset IFS
  21. export PYTHONPATH=$APP_HOME
  22. # run it
  23. case $1 in
  24. 'zhishu' )
  25. CLASS=yiis/data/neteasy_zhishu_loader.py
  26. "$PYTHON" $APP_HOME/$CLASS "$@"
  27. ;;
  28. 'stock' )
  29. echo "开始抓取。。。"
  30. CLASS=yiis/data/neteasy_stock_loader.py
  31. "$PYTHON" $APP_HOME/$CLASS "$@"
  32. echo "数据抓取结束。。。"
  33. echo "数据导入到数据库。"
  34. CLASS=yiis/data/process_stock_data.py
  35. "$PYTHON" $APP_HOME/$CLASS db
  36. echo "导入完成。"
  37. ;;
  38. *)
  39. echo 'usage: `basename $0` {zhishu|stock}'
  40. esac