Python で URL コンテンツを読み込み、タイトルを変数に解析する方法を見つけようとしています。
表示/読み込みされる URL データの例:
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" debug="true">
<script id="FirebugLite" firebugIgnore="true" extension="Chrome"/>
<song id="11450" parent="11042" title="30 Minutes Or Less (2011)" album="30 Minutes Or Less (2011)" isDir="false" created="2011-11-04T16:07:38" duration="4983" bitRate="1536" size="3521040154" suffix="mkv" contentType="video/x-matroska" isVideo="true" path="30 Minutes Or Less (2011)/30 Minutes Or Less (2011).mkv" transcodedSuffix="flv" transcodedContentType="video/x-flv"/>
</subsonic-response>
タイトルフィールドからデータを取得する方法はありますか? したがって、変数では「30 分以下 (2011)」になります。
フローコードを取得しましたが、動作させるのに問題があります。
import urllib, urllib2
from xml.etree.ElementTree import ElementTree
url = 'https://myurl.com'
root = urllib.urlopen(url).read()
tester = ElementTree.parse(root)
elem = ElementTree.find("title")
print elem
エラー: TypeError: バインドされていないメソッド parse() は、ElementTree インスタンスを最初の引数として呼び出す必要があります (代わりに str インスタンスを取得しました)