Форум сайта python.su
Помогите мне пожалуйста. Уже очень много тем посмотрел, но ничего не выходит.
from lxml.html import parse page = parse('http://ria.ru/religion/all.html').getroot() fc = page.find_class('b-list') print (fc)
for row in fc:
Отредактировано ashimano (Июнь 7, 2016 22:23:26)
Офлайн
Оно?
from lxml.html import parse, tostring page = parse('http://ria.ru/religion/all.html').getroot() fc = page.find_class('b-list') print(*(tostring(e) for e in fc), sep="\n")
Офлайн
http://lxml.de/lxmlhtml.html
.text_content():
Returns the text content of the element, including the text content of its children, with no markup.
>>> type(fc) <type 'list'>
<div class="b-list"> <div class="b-list__item"> <a href="/religion/20160608/1444696851.html"> <div class="b-list__item-story"> <div class="b-list__item-announce"> <div class="b-list__item-info"> </div>
>>> for x in fc: ... print x.text_content() ...
Отредактировано papuas (Июнь 8, 2016 22:27:55)
Офлайн