as an alternative to the Power Automate flow above, if you’re willing to run stuff directly from your web browser’s console, you can open up the console while you’re on any inaturalist.org page, and run the code below (making sure you change the user_id
value to whichever user you’re interested in).
as with the Power Automate flow, it effectively scrapes the user’s faves pages. but with this code, you won’t need anything beyond your web browser, and it’ll run a little faster / more efficiently.
async function getFavesBatch(user_id, page=1) {
return fetch(`https://www.inaturalist.org/faves/${user_id}?page=${page}`)
.then((response)=>{ return response.text(); })
.then((text)=>{
let parser = new DOMParser();
let doc = parser.parseFromString(text,'text/html');
let observations = doc.getElementsByClassName('observation');
let list = [];
for (let obs of observations) { list.push(obs.id.replace('observation-','')); };
let navigationChildren = doc.querySelector('[role=navigation]')?.children;
let maxBatch = ((typeof navigationChildren !== 'undefined') ? (navigationChildren[navigationChildren.length-2].innerText) : 1);
if (page===1) { console.log(`total pages: ${maxBatch}`); };
return {obsList:list, maxPage:maxBatch};
});
};
let user_id = 'kueda'
let obsList = [];
for (let [i,maxPage] = [1,1]; i<=maxPage; i++) {
let batchData = await getFavesBatch(user_id,i);
obsList.push(...batchData.obsList);
maxPage = batchData.maxPage;
console.log(`extracted page ${i}`);
};
console.log(obsList.join(','));