復習振り返り
- URL
- querystring
- module / require
- ルーティング
- SQL構文振り返り
今回利用したデータベーステーブルの情報
CREATE TABLE `bbs` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(20) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`content` text,
`timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8;
セキュリティ
- SQLインジェクション
- クロスサイトスクリプティング
- CSRF
- その他
フレームワーク
- 紹介(express, koa, hapi ,sails) -> https://speakerdeck.com/yosuke_furukawa/node-dot-js-web-application-survey-2016
- expressの利用 -> http://qiita.com/moomooya/items/00f89e425a3034b8ea14
- テンプレートエンジン
API利用、非同期処理
- collback hell
- 紹介(stream, promise, generater/yeld)
- ジーズアカデミースクレイピング (宿題)
- node-fetch -> https://www.npmjs.com/package/node-fetch
宿題
ジーズアカデミーのメンターの名前一覧を取得する機能を作りましょう。
ヒント
htmlを取得 -> HTMLから情報の抽出
という流れになります。
以下でhtmlの取得までができます。
gs_scraping.js
'use strict'
const http = require('http');
const URL = `http://gsacademy.tokyo/mentor/`;
http.get(URL, (res) => {
let body = '';
res.setEncoding('utf8');
res.on('data', (chunk) => {
body += chunk;
});
res.on('end', (res) => {
console.log(body); //ここでHTMLを取得できる
});
}).on('error', (e) => {
console.log(e.message); //エラー時
});
$ node gs_scraping.js
<!DOCTYPE html>
<html lang="ja" xml:lang="ja" prefix="og: http://ogp.me/ns# fb: http://www.facebook.com/2008/fbml">
<head>
・
・(省略)
・
こんな感じでHTMLを取得できます。
などを使ってパースしてみましょう。
↓
↓
完成イメージ
↓
↓
$ node gs_scraping.js
藤川真一
増渕大輔
岡本雄樹
今井智章
石倉 昇
宗定洋平
菅原のびすけ
中農 稔
竹添直樹
斉藤晋介