“beautifulsoup hallazgo” Código de respuesta

Usa beautifulsoup

#start


from bs4 import BeautifulSoup
import requests

req = requests.get('https://www.slickcharts.com/sp500')
soup = BeautifulSoup(req.text, 'html.parser')
Magnificent Moth

beautifulsoup encontrar clase

mydivs = soup.findAll("div", {"class": "stylelistrow"})
Tommyom

Niños Hermosas sopa

li = soup.find('li', {'class': 'text'})
children = li.findChildren("a" , recursive=False)
for child in children:
    print child
Long Lyrebird

beautifulsoup hallazgo

htmlTag = soup.find(id="id")
text = soup.find(id="id").get_text()
68Duck

Hermoso hallazgo de sopa

soup.title
# <title>The Dormouse's story</title>

soup.title.name
# u'title'

soup.title.string
# u'The Dormouse's story'

soup.title.parent.name
# u'head'

soup.p
# <p class="title"><b>The Dormouse's story</b></p>

soup.p['class']
# u'title'

soup.a
# <a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>

soup.find_all('a')
# [<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,
#  <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>,
#  <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>]

soup.find(id="link3")
# <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>
Happy Hedgehog

Respuestas similares a “beautifulsoup hallazgo”

Preguntas similares a “beautifulsoup hallazgo”

Más respuestas relacionadas con “beautifulsoup hallazgo” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código