“Linda sopa achada” Respostas de código

Use BeautifulSoup

#start


from bs4 import BeautifulSoup
import requests

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

BELAGEMSUPEL ENCONTRAR CLASSE

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

Linda sopa 4

from bs4 import BeautifulSoup

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

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

BeautifulSoup Find

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

Linda sopa achada

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

Respostas semelhantes a “Linda sopa achada”

Perguntas semelhantes a “Linda sopa achada”

Mais respostas relacionadas para “Linda sopa achada” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código