커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
메타 태그 활용한 크롤링 강의 응용 관련 문의
undefined주차
북마크
안*승
댓글
12
추천
0
조회수
14
조회수
14
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


http://webpedia.shop/


이렇게 일단 웹툰 /웹소설 리뷰를 할수 있게끔 해놨고 ..

메타 태그 통한 조각모음? 크롤링 통해서 진행할때 네이버 웹툰 기준으로 해서 그런지 카카오웹툰은 태그가 들어가질 않는데

이럴땐 어떻게 해야할까요?



<meta property="og:title" content="미생 | 카카오웹툰">


<meta property="og:title" content="완벽한 파트너">


검사를 해서 들어가보니 둘다 meta property 값은 있는듯한데..잘모르겠습니다 ㅠㅠ




스파르타 즉문즉답




작성한 코드 및 에러 메세지

app.py에 url이 지금 보니까 네이버로 되어있어서 그런듯한데 다음도 같이 하고싶으면 반복해서 크롤링을 해주면 될까요..?

def home():
   return render_template('index.html')

@app.route("/movie", methods=["POST"])
def movie_post():
    url_receive = request.form['url_give']
    star_receive = request.form['star_give']
    comment_receive = request.form['comment_give']

    url = 'https://comic.naver.com/webtoon/list?titleId=318995'

    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
    data = requests.get(url_receive, headers=headers)

    soup = BeautifulSoup(data.text, 'html.parser')

    title = soup.select_one('meta[property="og:title"]')['content']
    image = soup.select_one('meta[property="og:image"]')['content']
    desc = soup.select_one('meta[property="og:description"]')['content']

    doc={
        'title': title,
        'image': image,
        'desc': desc,
        'star': star_receive,
        'comment': comment_receive
    }

    db.weptoons.insert_one(doc)

    return jsonify({'msg':'저장 완료!'})

@app.route("/movie", methods=["GET"])
def movie_get():
    weptoons_list = list(db.weptoons.find({}, {'_id': False}))
    return jsonify({'weptoons':weptoons_list})

if __name__ == '__main__':
   app.run('0.0.0.0', port=5000, debug=True)


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴