Bird bark database. There is API that can be handled by json. This time, I used Python to collect all the calls of the genus Fulica (Coots) in Japan.
import requests
import json
import urllib
url = "https://www.xeno-canto.org/api/2/recordings?query=gen:Fulica+cnt:japan"
#get json(requests.get)
response = requests.get(url)
jsonData = response.json()["recordings"]
#Download section(The file name is{id}.mp3)
for data in jsonData:
url = ("http:"+data["file"])
title = data["id"]
urllib.request.urlretrieve(url,"{0}.mp3".format(title))
According to the Xeno-canto API documentation, the query is
gen
: common namesp
: specific namessp
: subsupecific nameen
: english namecnt
: country
Etc. can be specified.Of this time
url = "https://www.xeno-canto.org/api/2/recordings?query=gen:Fulica+cnt:japan"
Then, it is specified by gen: Fulica
, cut: Japan
.
url = ("http:"+data["file"])
In, the download url is in the key [" file "]
.
(Since http:
is not attached, add it.)
python 3.7.4 (Anaconda) MacOS Catalina 10.15.5
Recommended Posts