P
P
pecenuska21352021-09-07 23:03:33
Parsing
pecenuska2135, 2021-09-07 23:03:33

How to get content from html?

There is a downloaded html document. How to get a link from? import requests from bs4 import BeautifulSoup as bs<div> с набором <a class="some text" href= ... >6137c58f6ed76856628116.png

url = "https://wallscloud.net/wallpaper/nature/landscape/domik/RJ70"
r = requests.get(url)
print(r.status_code)
print(r.text)

soup = bs(r.text, "html.parser")
link = soup.find_all('a', class_='btn waves btn-block search_available_res starting_download waves-effect waves-light')
print(link)
#нужно получить ссылку кнопки

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SHADRIN, 2021-11-02
@pecenuska2135

Let's start with the fact that you get a list in response, in
soup.find_all(...)
order to get a link, you either look specifically or sort it out in a cycle

urls = [i.get('href') for i in soup.find_all(...)] # Это выдаст список ссылок по искомым элементам

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question