File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -14,15 +14,22 @@ export const getLinkInfo = async (link: string) => {
1414
1515 // ! TODO 크롤링에서 대략 초 단위 시간 소요 -> 개선 필요
1616 await axios
17- . get ( link )
17+ . get ( link , {
18+ headers : {
19+ 'User-Agent' : 'Mozilla/5.0 (compatible; OGCrawler/1.0)' ,
20+ } ,
21+ } )
1822 . then ( ( res ) => {
1923 if ( res . status !== 200 ) {
2024 throw new BadRequestException ( '잘못된 링크입니다.' ) ;
2125 } else {
2226 const data = res . data ;
2327 if ( typeof data === 'string' ) {
2428 const $ = cheerio . load ( data ) ;
25- title = $ ( 'title' ) . text ( ) !== '' ? $ ( 'title' ) . text ( ) : 'Untitled' ;
29+ title =
30+ $ ( 'title' ) . text ( ) !== ''
31+ ? $ ( 'title' ) . text ( ) || $ ( 'meta[name="title"]' ) . attr ( 'content' )
32+ : 'Untitled' ;
2633 $ ( 'meta' ) . each ( ( i , el ) => {
2734 const meta = $ ( el ) ;
2835 if ( meta . attr ( 'property' ) === 'og:image' ) {
You can’t perform that action at this time.
0 commit comments