“Temuan sup yang indah” Kode Jawaban

Gunakan Beautifulsoup

#start


from bs4 import BeautifulSoup
import requests

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

Kelas cantik menemukan

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

Sup indah 4

from bs4 import BeautifulSoup

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

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

Temukan cantik

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

Temuan sup yang indah

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

Jawaban yang mirip dengan “Temuan sup yang indah”

Pertanyaan yang mirip dengan “Temuan sup yang indah”

Lebih banyak jawaban terkait untuk “Temuan sup yang indah” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya