Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 1 month ago
JSON representation
Snippet of code to get your images from 500px.
- Host: GitHub
- URL: https://github.com/orsifrancesco/500px-json-rss-feed-api
- Owner: orsifrancesco
- License: mit
- Created: 2022-06-22T20:24:05.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-06-22T21:01:03.000Z (over 2 years ago)
- Last Synced: 2023-04-21T12:21:20.414Z (over 1 year ago)
- Topics: 500px, 500px-api, api, feed, json, no-api, rss
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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'); //