Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/orsifrancesco/500px-json-rss-feed-api

Snippet of code to get your images from 500px.
https://github.com/orsifrancesco/500px-json-rss-feed-api

500px 500px-api api feed json no-api rss

Last synced: about 4 hours ago
JSON representation

Snippet of code to get your images from 500px.

Awesome Lists containing this project

README

        

# 500px-json-rss-feed-api

## Code and example

Snippet of code to get your images from 500px. [Click here for a demo](https://orsifrancesco.github.io/500px-json-rss-feed-api/).

You can try with your images from 500px [#addingYour500pxUsername](https://orsifrancesco.github.io/500px-json-rss-feed-api/#orsifrancesco) at the end of the url.

```js

async function fetchData(username = '') {
if (!username) return []
const response = await fetch(`https://500px.com/${username}/rss`);
let data = await response.text();
data = data.replace(/\t/g, '');
const items = data.split('');
let json = [];
items.forEach(item => {
const title = item.match(/(.*?)<\/title>/g)?.map((val) => val?.replace(/<\/?title>/g, ''))?.[0]
const link = item.match(/(.*?)<\/link>/g)?.map((val) => val?.replace(/<\/?link>/g, ''))?.[0]
const pubDate = item.match(/(.*?)<\/pubDate>/g)?.map((val) => val?.replace(/<\/?pubDate>/g, ''))?.[0]
const img = item.match(//g)?.map((val) => val.replace(//g, ''))?.[0]
if (pubDate) json.push({ title, link, pubDate, img, epoch: parseInt(new Date(pubDate).getTime() / 1000) })
})
return json;
}

fetchData('orsifrancesco'); //