Code: Alles auswählen
from lxml import html
doc = html.fromstring('<html><a id="x_1"/><a id="x_2"/></html>')
print doc.xpath("//a/@id") #=> ['x_1', 'x_2']
Stefan
Code: Alles auswählen
from lxml import html
doc = html.fromstring('<html><a id="x_1"/><a id="x_2"/></html>')
print doc.xpath("//a/@id") #=> ['x_1', 'x_2']
Code: Alles auswählen
print [s[2:] for s in doc.xpath('//a/@id')]