ResourceSyncのPythonライブラリを試す
概要 ResourceSyncのPythonライブラリである「py-resourcesync」を試したので、その備忘録です。 https://github.com/resourcesync/py-resourcesync セットアップ git clone https://github.com/resourcesync/py-resourcesync cd py-resourcesync python setup install 実行 resourcelist まず、出力用のresource_dirディレクトリを作成します。カレントディレクトリにex_resource_dirフォルダが作成されます。 resource_dir = "ex_resource_dir" !mkdir -p $resource_dir 次に以下を実行します。適宜generatorを変更して使用するようですが、以下ではEgGeneratorというサンプルのものを使用しています。 from resourcesync.resourcesync import ResourceSync # from my_generator import MyGenerator from resourcesync.generators.eg_generator import EgGenerator my_generator = EgGenerator() metadata_dir = "ex_metadata_dir" # 適宜変更してください。 rs = ResourceSync(strategy=0, resource_dir=resource_dir, metadata_dir=metadata_dir) rs.generator = my_generator rs.execute() 結果、ex_resource_dir/ex_metadata_dirに、.well_known、capabilitylist.xml、resourcelist_0000.xmlが作成されます。 <?xml version='1.0' encoding='UTF-8'?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:rs="http://www.openarchives.org/rs/terms/"> <rs:ln href="http://www.example.com/.well-known/resourcesync" rel="up" /> <rs:md capability="capabilitylist" /> <url> <loc>http://www.example.com/metadata_dir/resourcelist_0000.xml</loc> <rs:md capability="resourcelist" /> </url> </urlset> <?xml version='1.0' encoding='UTF-8'?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:rs="http://www.openarchives.org/rs/terms/"> <rs:ln href="http://www.example.com/metadata_dir/capabilitylist.xml" rel="up" /> <rs:md at="2022-11-21T00:13:46Z" capability="resourcelist" completed="2022-11-21T00:13:46Z" /> <url> <loc>http://www.resourcesync.org</loc> <lastmod>2016-10-01T00:00:00Z</lastmod> <rs:md hash="md5:cc9895a21e335bbe66d61f2b62ce3a8e" length="20" type="application/xml" /> </url> </urlset> changelist strategyを1に変更することでnew_changelist、2に変更することでinc_changelistを作成することができました。 Resourcedump と Changedump strategyを3に変更することでresourcedump、4に変更することでchangedumpを作成できるようですが、これらについては設定方法を十分に理解することができず、未検証です。 ...















