I'm a beginner in programming and would like to do web scraping on Python.
At that time, I would like to specify the attribute name in XPath and get the attribute value, but the method is clear
I don't know.
Specifically,
<atitle="1" href="https://hogehoge.co.jp/">
If there is a tag called
and the attribute value "1" for the attribute name "title" is
I would like to get it.
What should I do?
Thank you very much for your kind instruction.
The environment is Python 3.6.4 and I use JupiterNotebook.
The browser is Google Chrome.
For XPath, use the
'//a/@title'
Yes.
Example in lxml.
from lxml.html import fromstring
el=fromstring('<a title="1" href="https://hogehoge.co.jp/">')
el.xpath('//a/@title')
['1']
© 2024 OneMinuteCode. All rights reserved.