Scrapy scraping Multiple items in one line

i cam is currently scraping a website using scrapy, and having a problem of

  1. getting multiple items which is in one line
  2. getting two text in one line.

gifen a code,


<dd class="star">
    
    
        
            <dl class="info_star">
                <dt class="tit_t1">users</dt>
                <dd>
                    <div class="star_t1">
                        <a href="/movie/bi/mi/point.naver?code=214637#pointAfterTab"><span class="st_off"><span class="st_on" style="width:71.2%"></span></span><span class="num">7.12</span><span class="num2"> <em>32</em>people</span></a><!-- N=a:nol.urating -->
                    </div>
                    
                    
                        <span class="split">|</span>
                    
                </dd>
                
                
                    
                        <dt class="tit_t2">critic</dt>
                        <dd>
                            <div class="star_t1">
                                <a href="/movie/bi/mi/point.naver?code=214637#pointExpertTab"><span class="st_off"><span class="st_on" style="width:56.7%"></span></span><span class="num">5.67</span><span class="num2"> <em>3</em>people</span></a><!-- N=a:nol.crating -->
                            </div>
                        </dd>
                    
                
            </dl>
                
            
    
</dd>
<dd>
    <dl class="info_txt1">
    <dt class="tit_t1">overview</dt>
    <dd>
        
        <span class="link_txt">
            
                <a href="/movie/sdb/browsing/bmovie.naver?genre=15">animation</a><!-- N=a:nol.genre,r:1 -->, 
            
                <a href="/movie/sdb/browsing/bmovie.naver?genre=12">comedy</a><!-- N=a:nol.genre,r:2 -->, 
            
                <a href="/movie/sdb/browsing/bmovie.naver?genre=11">thriller</a><!-- N=a:nol.genre,r:3 -->
            
        </span>
        
            <span class="split">|</span>
            59 minutes
        
            <span class="split">|</span>
            2022.05.05 release
        
    </dd>
    
    
    <dt class="tit_t2">director</dt>
    <dd>
        <span class="link_txt">
            
                <a href="/movie/bi/pi/basic.naver?code=330883">spielberg</a><!-- N=a:nol.director,r:1 -->
            
        </span>
    </dd>
    
    
    
    
    </dl>
</dd>
                
    <a href="/movie/bi/mi/basic.naver?code=195178">scary movie</a>
    <!-- N=a:nol.title,r:2,i:195178 -->
</dt>


<dd class="star">
    
            <dl class="info_star">
                <dt class="tit_t1">user</dt>
                <dd>
                    <div class="star_t1">
                        <a href="/movie/bi/mi/point.naver?code=195178#pointAfterTab"><span class="st_off"><span class="st_on" style="width:100.0%"></span></span><span class="num">10.00</span><span class="num2">참여 <em>7</em>명</span></a><!-- N=a:nol.urating -->
                    </div>
                    
                    
                        <span class="split">|</span>
                    
                </dd>
                
                    
                        <dt class="tit_t2">reviewer</dt>
                        <dd>
                            <div class="star_t1">
                                <a href="/movie/bi/mi/point.naver?code=195178#pointExpertTab"><span class="st_off"><span class="st_on" style="width:50.0%"></span></span><span class="num">5.00</span><span class="num2">참여 <em>1</em>명</span></a><!-- N=a:nol.crating -->
                            </div>
                        </dd>
                    
                
            </dl>
                
    
    
</dd>
<dd>
    <dl class="info_txt1">
    <dt class="tit_t1">overview</dt>
    <dd>
        
        <span class="link_txt">
            
                <a href="/movie/sdb/browsing/bmovie.naver?genre=19">action</a><!-- N=a:nol.genre,r:1 -->
            
        </span>
        
            <span class="split">|</span>
            99 minutes
            <span class="split">|</span>
            2022.05.05 release
        
    </dd>
    
    
    <dt class="tit_t2">director</dt>
    <dd>
        <span class="link_txt">
            
                <a href="/movie/bi/pi/basic.naver?code=51674">johhny depp</a><!-- N=a:nol.director,r:1 -->
            
        </span>
    </dd>
    
    
    
    <dt class="tit_t3">출연</dt>
    <dd>
        <span class="link_txt">
            
                <a href="/movie/bi/pi/basic.naver?code=414969">tom holland</a><!-- N=a:nol.actor,r:1 -->, 
            
                <a href="/movie/bi/pi/basic.naver?code=423140">actor 3</a><!-- N=a:nol.actor,r:2 -->, 
            
                <a href="/movie/bi/pi/basic.naver?code=448396">actor 3</a><!-- N=a:nol.actor,r:3 -->, 
            
                <a href="/movie/bi/pi/basic.naver?code=428181">actor 4</a><!-- N=a:nol.actor,r:4 -->
            
        </span>
    </dd>
    
    
    </dl>
</dd>
                        
<dd class="info_t1">
    <div class="btn_area">
        
            <a href="/movie/bi/mi/running.naver?code=195178" class="btn_rsv">예매하기</a><!-- N=a:nol.ticket,r:2,i:195178 -->
        
        
        <span class="btn_t1">
        
            
                <a href="/movie/bi/mi/photoView.naver?code=195178" class="item1">포토보기</a><!-- N=a:nol.photo,r:2,i:195178 -->
            
            
            
                <a href="/movie/bi/mi/mediaView.naver?code=195178&mid=52320#tab" class="item2">예고편</a><!-- N=a:nol.trailer,r:2,i:195178 -->
            
            

                    

(I copied a code from https://movie.naver.com/movie/running/current.naver this site, but this site is in korean.)

So what I want to do is, I want to get multiple texts in one line into list like in below code, [animation, comedy, thriller]. I used scope = movie_sel.css('.link_txt > a::text').get() print(scope) but it’ll give me only one element.

Also, I want to

    <span class="link_txt">
                                
                                    <a href="/movie/sdb/browsing/bmovie.naver?genre=15">animation</a><!-- N=a:nol.genre,r:1 -->, 
                                
                                    <a href="/movie/sdb/browsing/bmovie.naver?genre=12">comedy</a><!-- N=a:nol.genre,r:2 -->, 
                                
                                    <a href="/movie/sdb/browsing/bmovie.naver?genre=11">thriller</a><!-- N=a:nol.genre,r:3 -->
                                

  1. Also, I want to get the ratings and people who rated. Because it is in the same name, I can’t seem to get two items.

I tried netizen_rate = movie_sel.css('div.star_t1 > a > span.num::text').get()
but when I try to get the ratings of 5.67, It gets confused.

                        
                        
                            
                                <dl class="info_star">
                                    <dt class="tit_t1">users</dt>
                                    <dd>
                                        <div class="star_t1">
                                            <a href="/movie/bi/mi/point.naver?code=214637#pointAfterTab"><span class="st_off"><span class="st_on" style="width:71.2%"></span></span><span class="num">7.12</span><span class="num2"> <em>32</em>people</span></a><!-- N=a:nol.urating -->
                                        </div>
                                        
                                        
                                            <span class="split">|</span>
                                        
                                    </dd>
                                    
                                    
                                        
                                            <dt class="tit_t2">critic</dt>
                                            <dd>
                                                <div class="star_t1">
                                                    <a href="/movie/bi/mi/point.naver?code=214637#pointExpertTab"><span class="st_off"><span class="st_on" style="width:56.7%"></span></span><span class="num">5.67</span><span class="num2"> <em>3</em>people</span></a><!-- N=a:nol.crating -->
                                                </div>
                                            </dd>
                                        
                                    
                                </dl>
  1. Also, I want to separate the minutes and release date, but can’t do it with only using the dd tag.

It’s a long question… but can you guys help me out? Thank you.

Leave a Comment