전언석

edit reply.js

......@@ -21,16 +21,8 @@ app.post('/hook', function (req, res) {
// request log
console.log('======================', new Date(), '======================');
console.log('[request]', req.body);
console.log('[request source] ', eventObj.source);
console.log('[request message]', eventObj.message);
var incredients_list = message.text.split(" ");
function findingredients(item) { return item === "김치"; }
// mwsql
// mysql -u chatbot -p -h chatbot.c7fzgftc3yrm.us-east-1.rds.amazonaws.com
var mysql = require('mysql');
var db = mysql.createConnection({
host: 'chatbot.c7fzgftc3yrm.us-east-1.rds.amazonaws.com',
......@@ -60,11 +52,11 @@ app.post('/hook', function (req, res) {
"messages": [
{
"type": "text",
"text": `${results[i].menu}`
"text": `메뉴는 "${results[i].menu}" 입니다.`
},
{
"type": "text",
"text": `${results[i].recipe}`
"text": `레시피\n${results[i].recipe}`
}
]
}
......@@ -91,5 +83,4 @@ try {
} catch (error) {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.log(error);
}
}
\ No newline at end of file
......
// var xhr = new XMLHttpRequest();
// var url = 'http://apis.data.go.kr/1390802/AgriFood/FdCkry/getKoreanFoodFdCkryList'; /*URL*/
// var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'R7bFhjvvAMmxJxzcrL8NWkYHVa227zfpwvpwgXxcixNdMY0EbdbsbCboj3zXEsXniKNHyqu2dEllJCRk1LsdxA%3D%3D'; /*Service Key*/
// queryParams += '&' + encodeURIComponent('service_Type') + '=' + encodeURIComponent('xml'); /**/
// queryParams += '&' + encodeURIComponent('Page_No') + '=' + encodeURIComponent('1'); /**/
// queryParams += '&' + encodeURIComponent('Page_Size') + '=' + encodeURIComponent('20'); /**/
// queryParams += '&' + encodeURIComponent('food_Name') + '=' + encodeURIComponent('밥'); /**/
// queryParams += '&' + encodeURIComponent('ckry_Name') + '=' + encodeURIComponent('조리'); /**/
// xhr.open('GET', url + queryParams);
// xhr.onreadystatechange = function () {
// if (this.readyState == 4) {
// alert('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText);
// }
// };
// xhr.send('');
var XMLHttpRequest = require('xhr2');
var xhr = new XMLHttpRequest();
var url = 'http://apis.data.go.kr/1390802/AgriFood/FdCkry/getKoreanFoodFdCkryList'; /*URL*/
var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'R7bFhjvvAMmxJxzcrL8NWkYHVa227zfpwvpwgXxcixNdMY0EbdbsbCboj3zXEsXniKNHyqu2dEllJCRk1LsdxA%3D%3D'; /*Service Key*/
......@@ -9,7 +27,11 @@ queryParams += '&' + encodeURIComponent('ckry_Name') + '=' + encodeURIComponent(
xhr.open('GET', url + queryParams);
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
alert('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText);
//console.log('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText);
//console.log(this.responseText);
console.log(this.responseText);
console.log("hehe\n");
console.log(queryParams);
}
};
......
......@@ -3,14 +3,14 @@ import requests
from bs4 import BeautifulSoup
import pymysql
#pip3 install requests, pip3 install pymyaql, pip3 install beautifulsoup4를 하고 진행, pip3대신 pip 사용가능
#pip3 install requests, pip3 install pymysql, pip3 install beautifulsoup4를 하고 진행, pip3대신 pip 사용가능
#사이트가 크롤링을 공격으로 인식하는 것을 방지하기 위해 중간중간에 sleep함수를 사용
conn = pymysql.connect(host="localhost", user="root",password='abcde12345abcde',db='db_recipe', charset='utf8')
curs = conn.cursor(pymysql.cursors.DictCursor)
for pagenum in range(1,35): #크롤링 할 상위 페이지 개수. 약 40개정도의 레시피 링크가 한 페이지에 이어져 있음
for pagenum in range(1,2): #크롤링 할 상위 페이지 개수. 약 40개정도의 레시피 링크가 한 페이지에 이어져 있음
print(pagenum)
page = requests.get('https://www.10000recipe.com/recipe/list.html?order=reco&page='+str(pagenum))
......