0

I would like to know how can I get everything from the list using a python scraper. This I want to take http://prntscr.com/dged67 I figured out how to get it but it has some ugly tags I want to get rid of.

info = soup.findAll('ul',{'class':'list-unstyled pull-left custom-stats'})
    print info    

This is the code I'm using. This is what I'm getting http://prntscr.com/dgedzu

1
  • 1
    don't use pictures. It's cumbersome to type over text so you would get less help Commented Dec 7, 2016 at 11:07

2 Answers 2

1

based on your html:

from bs4 import BeautifulSoup

soup = BeautifulSoup(open("web.html"), "html.parser")
divs = soup.findAll('div',{'class':'pull-left custom-photo-modal-stats'})
for div in divs:
    for listItem in div.find_all('li'):
       print listItem.getText()
Sign up to request clarification or add additional context in comments.

1 Comment

Still prints me what I was getting before I wanna take just the info without html if possible. Thank you for your answer
0
    <div class="pull-left custom-photo-modal-stats">
                        <h3>Stats</h3>
                        <ul class="list-unstyled pull-left custom-stats">
                            <li><span class="highlight">Eye color:</span> hazel</li>
                            <li><span class="highlight">Hair color:</span> brown</li>
                            <li><span class="highlight">Height:</span> 5'5"</li>
                            <li><span class="highlight">Weight:</span> 110 lbs</li>
                        </ul>
                        <ul class="list-unstyled pull-left custom-stats custom-stats-right">
                            <li><span class="highlight">Breasts:</span> medium</li>
                            <li><span class="highlight">Size:</span> 34/24/37</li>
                            <li><span class="highlight">Shaved:</span> shaved</li>
                            <li><span class="highlight">Ethnicity:</span> Caucasian</li>
                        </ul>
                    </div>

2 Comments

This is the html im trying to get
prntscr.com/dhs43v I figured out how to get all this but now I want to get only <li> objects to have for example Eye Color : hazel \n Hair Color: red

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.