import requests
from bs4 import BeautifulSoup
url = "https://toss.im/"
res = requests.get(url)
res.raise_for_status
soup = BeautifulSoup(res.text, "lxml")
toss = soup.find("li", attrs={"class":"p-navbar__item"})
print(toss.find_next_siblings("li"))
Do you know how to print out only text from this code?
print(toss.find_next_siblings("li").get_text())
but it doesn't work.
I don't know why you convert the html page to lxml.
import requests
from bs4 import BeautifulSoup
url = "https://toss.im/"
res = requests.get(url)
soup = BeautifulSoup(res.text, "html.parser")
print(soup.select_one('li'))
© 2024 OneMinuteCode. All rights reserved.