Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grimmer0125/applecrawler-node
[deprecated, line api has been changed] Line Bot + Automation Bot for Grabbing Apple Product Info. on server side. It uses PostgreSQL and Heroku. Complement: Execute "psql [database] [dbuser] table.sql" before coding. If you are using "postgresapp" on macOS, there is some default db/user setting, https://postgresapp.com/.
https://github.com/grimmer0125/applecrawler-node
Last synced: 7 days ago
JSON representation
[deprecated, line api has been changed] Line Bot + Automation Bot for Grabbing Apple Product Info. on server side. It uses PostgreSQL and Heroku. Complement: Execute "psql [database] [dbuser] table.sql" before coding. If you are using "postgresapp" on macOS, there is some default db/user setting, https://postgresapp.com/.
- Host: GitHub
- URL: https://github.com/grimmer0125/applecrawler-node
- Owner: grimmer0125
- Created: 2016-06-30T12:38:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-12T01:39:44.000Z (over 6 years ago)
- Last Synced: 2024-12-22T00:23:43.264Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# appleCrawler
[](https://travis-ci.org/grimmer0125/appleCrawler-node)
Use "request" + "cheerio" to grab the content of http://www.apple.com/tw/shop/browse/home/specialdeals/mac, then use Line to broadcast the information. Actually this project is more like a scraper but not change the repo name to keep the consistence.
## Steps for development:
1. (Optional) Install the latest version of Node.js from [https://nodejs.org/en/](https://nodejs.org/en/)
2. Go to the project root folder.
3. Type `npm install` to install npm dependencies.
4. (Optional) Change the enviornment PORT to what you want. This is the server's port and default is `5000`.
4. Setup credentials for Line Bot. Also you need to fill your server's Domain name to Line Developer Center so that your Line BOT can receive messages. Otherwise this Line bot only can send. It means your Local server/developement always can send messanges only. (Line server can not reach localhost)
5. (Optional) Setup credentials forTwilio.
6. Setup Postgresql database. If you use Heroku on production, you can follow [https://devcenter.heroku.com/articles/getting-started-with-nodejs#provision-a-database](https://devcenter.heroku.com/articles/getting-started-with-nodejs#provision-a-database). Once you have setup, setup the enviorment DATABASE_URL to yours. E.g., postgres://yourPostgresURL. If you do not specify DATABASE_URL, it will look for the DB on the same machine and use login user account, since `"start": "DATABASE_URL=postgres:///$(whoami) node index.js"`.
7. Run `npm start` to launch the application.## How to setup enviornment variable in Node.js, there are several ways.
1. Unix/Linux way: use Export.
2. Package.json way: "start": "PORT=1234 node server.js",
3. Heroku way (need to use heroku local): [https://devcenter.heroku.com/articles/getting-started-with-nodejs#define-config-vars](https://devcenter.heroku.com/articles/getting-started-with-nodejs#define-config-vars)## Fill the credentials of Line Bot API
~~~ javascript
const client = LineBot.client({
channelID: '',
channelSecret: '',
channelMID: ''
});
~~~## (Optional) Fill the credentials of Twilio API (when reaching the maximal number of the friends of Line Bot, send the alarm)
~~~ javascript
const accountSid = 'Twilio Account SID';
const authToken = 'Twilio API Token';
const twilioClient = require('twilio')(accountSid, authToken);twilioClient.messages.create({
to: 'your phone number',
from: 'your Twilio number',
body: 'Line bot has problems !!',
}, function (err, message) {
console.log(message.sid);
});
~~~##
## License
appleCrawler-node is released under the Apache 2.0 license.