“Hermoso hallazgo de sopa” 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

Hermosa sopa 4

from bs4 import BeautifulSoup

with open("index.html") as fp:
    soup = BeautifulSoup(fp)

soup = BeautifulSoup("<html>a web page</html>")
arkyyadav001

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 “Hermoso hallazgo de sopa”

Preguntas similares a “Hermoso hallazgo de sopa”

Más respuestas relacionadas con “Hermoso hallazgo de sopa” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código