ダ
<a class="news__title" href="линк">текст</a>
как извлечь оттуда хреф, то есть линк?
url = answer.find('a',class_='news__title').a.get('href')
Этот метод не работает. В чем ошибка?
Size: a a a
ダ
<a class="news__title" href="линк">текст</a>
url = answer.find('a',class_='news__title').a.get('href')
ダ
ダ
<a class="news__title" href="линк">текст</a>
url = answer.find('a',class_='news__title').a.get('href')
OK
ダ
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
link_text = “”
for a in soup.find_all(‘a’, href=True, text=True):
link_text = a[‘href’]
print “Link: “ + link_text
ダ
href_tags = soup.find_all(href=True)
ダ
from BeautifulSoup import BeautifulSoup
html = '''<a href="some_url">next</a>
<span class="class"><a href="another_url">later</a></span>'''
soup = BeautifulSoup(html)
for a in soup.find_all('a', href=True):
print "Found the URL:", a['href']
ダ
def parse(html):
soup = BeautifulSoup(html,'html.parser')
title = soup.find('h1')
image1 = soup.find_all('a', class_='highslide')[0]
image2 = soup.find_all('a', class_='highslide')[1]
post = []
post.append ({
'title': title.text,
'image1': image1.get('href'),
'image2': image2.get('href'),
})
print(post)
ダ
import BeautifulSoup
soup = BeautifulSoup.BeautifulSoup(html)
for link in soup.findAll("a"):
print link.get("href")
A
A
A
<a class="news__title" href="линк">текст</a>
url = answer.find('a',class_='news__title').a.get('href')
A
OK
row
один с айди. Мой код:answers = soup.find('div',class_='row').find_all('div',class_='col-md-4 mb-25 l-item')
думаю нужно добавить и id
туда. А как добавить не знаю.т
row
один с айди. Мой код:answers = soup.find('div',class_='row').find_all('div',class_='col-md-4 mb-25 l-item')
думаю нужно добавить и id
туда. А как добавить не знаю.OV
OK
т
т
OK