Showing
6 changed files
with
40 additions
and
68 deletions
| ... | @@ -2,15 +2,4 @@ | ... | @@ -2,15 +2,4 @@ |
| 2 | ## CHATBOT WITH CRAWLING | 2 | ## CHATBOT WITH CRAWLING |
| 3 | 3 | ||
| 4 | front | 4 | front |
| 5 | -- [x] Modify card component | ||
| 6 | -- [x] Remove card message on dialogflow | ||
| 7 | -- [ ] Modify Intent on dialogflow | ||
| 8 | -- [ ] Add additional functions on dialogflow | ||
| 9 | -- [x] Show video list on front (card compo) | ||
| 10 | - | ||
| 11 | -back | ||
| 12 | -- [ ] Modify crawling.js to deal with null data | ||
| 13 | -- [ ] Dealing with Event queries | ||
| 14 | -- [ ] 가수와 관련되지 않은 영상이 포함될 땐? | ||
| 15 | -- [ ] 배포 어떻게 할것인가 | ||
| 16 | -- [ ] 전반적인 내용 완전히 이해하기 (구조 등) | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 5 | +- 뉴스 크롤링 후 이미지 사이자 80*80 인 것을 원본으로 변환할 수 있는 방법은..? | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -15,7 +15,7 @@ function Chatbot() { | ... | @@ -15,7 +15,7 @@ function Chatbot() { |
| 15 | useEffect(() => { | 15 | useEffect(() => { |
| 16 | 16 | ||
| 17 | eventQuery('001_Welcome') | 17 | eventQuery('001_Welcome') |
| 18 | - eventQuery('002_Intro') | 18 | + .then(eventQuery('002_Intro')) |
| 19 | 19 | ||
| 20 | }, []) | 20 | }, []) |
| 21 | 21 | ||
| ... | @@ -54,6 +54,7 @@ function Chatbot() { | ... | @@ -54,6 +54,7 @@ function Chatbot() { |
| 54 | response = await Axios.post('/api/related/textQuery', textQueryVariables) | 54 | response = await Axios.post('/api/related/textQuery', textQueryVariables) |
| 55 | } | 55 | } |
| 56 | else if(inputString === '소식'){ //@가수명_소식 | 56 | else if(inputString === '소식'){ //@가수명_소식 |
| 57 | + console.log("뉴스들어옴") | ||
| 57 | response = await Axios.post('/api/news/textQuery', textQueryVariables) | 58 | response = await Axios.post('/api/news/textQuery', textQueryVariables) |
| 58 | } | 59 | } |
| 59 | 60 | ||
| ... | @@ -182,12 +183,6 @@ function Chatbot() { | ... | @@ -182,12 +183,6 @@ function Chatbot() { |
| 182 | </div> | 183 | </div> |
| 183 | } | 184 | } |
| 184 | 185 | ||
| 185 | - | ||
| 186 | - // template for card message | ||
| 187 | - | ||
| 188 | - | ||
| 189 | - | ||
| 190 | - | ||
| 191 | } | 186 | } |
| 192 | 187 | ||
| 193 | const renderMessage = (returnedMessages) => { | 188 | const renderMessage = (returnedMessages) => { |
| ... | @@ -207,7 +202,7 @@ function Chatbot() { | ... | @@ -207,7 +202,7 @@ function Chatbot() { |
| 207 | height: 650, width: 700, | 202 | height: 650, width: 700, |
| 208 | border: '3px solid black', borderRadius: '7px' | 203 | border: '3px solid black', borderRadius: '7px' |
| 209 | }}> | 204 | }}> |
| 210 | - <div style={{ height: 594, width: '100%', overflow: 'auto' }}> | 205 | + <div style={{ height: 594, width: '100%', overflow: 'auto'}}> |
| 211 | 206 | ||
| 212 | 207 | ||
| 213 | {renderMessage(messagesFromRedux)} | 208 | {renderMessage(messagesFromRedux)} |
| ... | @@ -217,7 +212,7 @@ function Chatbot() { | ... | @@ -217,7 +212,7 @@ function Chatbot() { |
| 217 | <input | 212 | <input |
| 218 | style={{ | 213 | style={{ |
| 219 | margin: 0, width: '100%', height: 50, | 214 | margin: 0, width: '100%', height: 50, |
| 220 | - borderRadius: '4px', padding: '5px', fontSize: '1rem' | 215 | + borderRadius: '4px', padding: '5px', fontSize: '1rem', fontFamily: 'KyoboHand' |
| 221 | }} | 216 | }} |
| 222 | placeholder="Send a message..." | 217 | placeholder="Send a message..." |
| 223 | onKeyPress={keyPressHanlder} | 218 | onKeyPress={keyPressHanlder} | ... | ... |
| ... | @@ -8,11 +8,12 @@ function CardComponent(props) { | ... | @@ -8,11 +8,12 @@ function CardComponent(props) { |
| 8 | console.log("props" ,props) | 8 | console.log("props" ,props) |
| 9 | return ( | 9 | return ( |
| 10 | <Card | 10 | <Card |
| 11 | - style={{ width: 200 }} | 11 | + style={{ width: 180}} |
| 12 | cover={ | 12 | cover={ |
| 13 | <img | 13 | <img |
| 14 | alt={props.cardInfo.description} | 14 | alt={props.cardInfo.description} |
| 15 | - src={props.cardInfo.image} /> | 15 | + src={props.cardInfo.image} |
| 16 | + /> | ||
| 16 | } | 17 | } |
| 17 | actions={[ | 18 | actions={[ |
| 18 | <a target="_blank" rel="noopener noreferrer" href={props.cardInfo.link}> | 19 | <a target="_blank" rel="noopener noreferrer" href={props.cardInfo.link}> |
| ... | @@ -29,32 +30,4 @@ function CardComponent(props) { | ... | @@ -29,32 +30,4 @@ function CardComponent(props) { |
| 29 | 30 | ||
| 30 | ) | 31 | ) |
| 31 | } | 32 | } |
| 32 | - | ||
| 33 | - | ||
| 34 | -/* | ||
| 35 | -function CardComponent(props) { | ||
| 36 | - return ( | ||
| 37 | - <Card | ||
| 38 | - style={{ width: 300 }} | ||
| 39 | - cover={ | ||
| 40 | - <img | ||
| 41 | - alt={props.cardInfo.fields.description.stringValue} | ||
| 42 | - src={props.cardInfo.fields.image.stringValue} /> | ||
| 43 | - } | ||
| 44 | - actions={[ | ||
| 45 | - <a target="_blank" rel="noopener noreferrer" href={props.cardInfo.fields.link.stringValue}> | ||
| 46 | - <Icon type="ellipsis" key="ellipsis" /> | ||
| 47 | - </a> | ||
| 48 | - ]} | ||
| 49 | - > | ||
| 50 | - <Meta | ||
| 51 | - title={props.cardInfo.fields.title.stringValue} | ||
| 52 | - description={props.cardInfo.fields.description.stringValue} | ||
| 53 | - /> | ||
| 54 | - | ||
| 55 | - </Card> | ||
| 56 | - | ||
| 57 | - ) | ||
| 58 | -} | ||
| 59 | -*/ | ||
| 60 | export default CardComponent | 33 | export default CardComponent | ... | ... |
| 1 | -@import url('https://fonts.googleapis.com/css2?family=Nanum+Gothic&display=swap'); | 1 | +@font-face { |
| 2 | + font-family: 'KyoboHand'; | ||
| 3 | + src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_20-04@1.0/KyoboHand.woff') format('woff'); | ||
| 4 | + font-weight: normal; | ||
| 5 | + font-style: normal; | ||
| 6 | +} | ||
| 7 | + | ||
| 2 | * { | 8 | * { |
| 3 | word-break: keep-all; | 9 | word-break: keep-all; |
| 4 | overflow-wrap: break-word; | 10 | overflow-wrap: break-word; |
| ... | @@ -8,26 +14,30 @@ | ... | @@ -8,26 +14,30 @@ |
| 8 | html, | 14 | html, |
| 9 | body { | 15 | body { |
| 10 | max-height: 800px; | 16 | max-height: 800px; |
| 17 | + font-family: 'KyoboHand'; | ||
| 11 | } | 18 | } |
| 12 | 19 | ||
| 13 | body { | 20 | body { |
| 14 | margin: 0; | 21 | margin: 0; |
| 15 | padding: 0; | 22 | padding: 0; |
| 16 | - font-family: Nanum Gothic,Lato, Helvetica Neue, Arial, Helvetica, sans-serif; | 23 | + font-family: 'KyoboHand','Nanum Gothic',Lato, Helvetica Neue, Arial, Helvetica, sans-serif; |
| 17 | -webkit-font-smoothing: antialiased; | 24 | -webkit-font-smoothing: antialiased; |
| 18 | } | 25 | } |
| 19 | 26 | ||
| 20 | .ant-list-item-meta-content { | 27 | .ant-list-item-meta-content { |
| 21 | max-width: 500px; | 28 | max-width: 500px; |
| 22 | overflow-x: scroll; | 29 | overflow-x: scroll; |
| 30 | + font-family: 'KyoboHand'; | ||
| 23 | } | 31 | } |
| 24 | 32 | ||
| 25 | .ant-list-item-meta-title { | 33 | .ant-list-item-meta-title { |
| 26 | font-size: 20px !important; | 34 | font-size: 20px !important; |
| 35 | + font-family: 'KyoboHand'; | ||
| 27 | } | 36 | } |
| 28 | 37 | ||
| 29 | .ant-list-item-meta-description { | 38 | .ant-list-item-meta-description { |
| 30 | display: flex; | 39 | display: flex; |
| 31 | color: black !important; | 40 | color: black !important; |
| 41 | + font-family: 'KyoboHand'; | ||
| 32 | } | 42 | } |
| 33 | 43 | ... | ... |
| ... | @@ -9,16 +9,20 @@ const cheerio = require('cheerio'); | ... | @@ -9,16 +9,20 @@ const cheerio = require('cheerio'); |
| 9 | 9 | ||
| 10 | router.post('/textQuery', async(req,res)=>{ | 10 | router.post('/textQuery', async(req,res)=>{ |
| 11 | const result = req.body.text; | 11 | const result = req.body.text; |
| 12 | - var name = result.substring(1) | 12 | + var i = 0; |
| 13 | - | 13 | + for(i; i < result.length; i++){ |
| 14 | - var url = 'https://tv.naver.com/search/clip?query=' //naverTV의 링크 | 14 | + if(result[i] === '_') break; |
| 15 | - var sort = '&sort=date' | 15 | + } |
| 16 | - url = url + name + sort | 16 | + var name = result.substr(1,i-1); |
| 17 | + | ||
| 18 | + var url = 'https://search.naver.com/search.naver?query=' //naverTV의 링크 | ||
| 19 | + var where = '&where=news' | ||
| 20 | + url = url + name + where | ||
| 17 | url = encodeURI(url) | 21 | url = encodeURI(url) |
| 18 | console.log("url is ",url) | 22 | console.log("url is ",url) |
| 19 | const getHtml = async() => { | 23 | const getHtml = async() => { |
| 20 | try{ | 24 | try{ |
| 21 | - return await axios.get(url); //axios.get 함수를 이용해서 비동기로 네이버티비의 해당 가수의 최신 영상 html 파일을 가져온다. | 25 | + return await axios.get(url); //axios.get 함수를 이용해서 비동기로 네이버 뉴스 중 해당 가수의 이름이 들어간 최신 뉴스 html 파일을 가져온다. |
| 22 | } catch(error){ | 26 | } catch(error){ |
| 23 | console.log("error! check your code"); | 27 | console.log("error! check your code"); |
| 24 | } | 28 | } |
| ... | @@ -26,20 +30,21 @@ router.post('/textQuery', async(req,res)=>{ | ... | @@ -26,20 +30,21 @@ router.post('/textQuery', async(req,res)=>{ |
| 26 | 30 | ||
| 27 | getHtml() | 31 | getHtml() |
| 28 | .then(html => { | 32 | .then(html => { |
| 29 | - let videoList = []; | 33 | + let newsList = []; |
| 30 | const $ = cheerio.load(html.data); | 34 | const $ = cheerio.load(html.data); |
| 31 | - const $bodyList = $("div.src_wrap div.thl ").children("div.thl_a"); | 35 | + const $bodyList = $("div.news").children("ul.type01").children("li"); |
| 36 | + | ||
| 32 | 37 | ||
| 33 | $bodyList.each(function(i, elem){ | 38 | $bodyList.each(function(i, elem){ |
| 34 | - videoList[i] = { | 39 | + newsList[i] = { |
| 35 | - description : "naverTV", | 40 | + description : "네이버 검색 기사", |
| 36 | - image : $(this).find('a.cds_thm').children('img').attr('src'), | 41 | + title : $(this).find('a._sp_each_title').attr('title'), |
| 37 | - title : $(this).find('a.cds_thm').attr('title'), | 42 | + link : $(this).find('a._sp_each_title').attr('href'), |
| 38 | - link : "https://tv.naver.com/" + $(this).find('a.cds_thm').attr('href') | 43 | + image : $(this).find('a.sp_thmb').children('img').attr('src') |
| 39 | } | 44 | } |
| 40 | }) | 45 | }) |
| 41 | 46 | ||
| 42 | - data = videoList.filter(n => n.title); | 47 | + data = newsList.filter(n => n.title); |
| 43 | data = JSON.stringify(data.slice(0,3)) | 48 | data = JSON.stringify(data.slice(0,3)) |
| 44 | 49 | ||
| 45 | res.send(data); | 50 | res.send(data); | ... | ... |
| ... | @@ -24,7 +24,7 @@ router.post('/textQuery', async(req,res)=>{ | ... | @@ -24,7 +24,7 @@ router.post('/textQuery', async(req,res)=>{ |
| 24 | console.log("url is ",url) | 24 | console.log("url is ",url) |
| 25 | const getHtml = async() => { | 25 | const getHtml = async() => { |
| 26 | try{ | 26 | try{ |
| 27 | - return await axios.get(url); //axios.get 함수를 이용해서 비동기로 네이버티비의 해당 가수의 최신 영상 html 파일을 가져온다. | 27 | + return await axios.get(url); //axios.get 함수를 이용해서 비동기로 네이버티비의 해당 가수의 이름과 정확도가 높은 html 파일을 가져온다. |
| 28 | } catch(error){ | 28 | } catch(error){ |
| 29 | console.log("error! check your code"); | 29 | console.log("error! check your code"); |
| 30 | } | 30 | } | ... | ... |
-
Please register or login to post a comment