ElementTree findall() returning empty list

前端 未结 1 1504
鱼传尺愫
鱼传尺愫 2020-12-05 18:21

I am trying to write a small script for interacting with the last.fm API.

I have a small bit of experience working with ElementTree, but the way I used

相关标签:
1条回答
  • 2020-12-05 18:42

    The problem is that findall only searches the immediate descendants of an element if it is given a tag name. You need to give it an XPath expression that will find track anywhere in the tree beneath it. So the following should work, for example:

    api_results = ElementTree.parse(response).findall('.//track')
    
    0 讨论(0)
提交回复
热议问题