JSFiddle - React, Tailwind, and code Playground
by huppen
JavaScript
var urls = [
'https://meetingpoint-brandenburg.de/'
// Add more URLs as needed
];
// Function to fetch data and generate the RSS feed
function generateRSSFeed() {
// Create the root XML element for the RSS feed
var rssFeed = $('<rss/>').attr({
version: '2.0',
xmlns: 'http://www.w3.org/2005/Atom',
});
// Create the channel element
var channel = $('<channel/>').appendTo(rssFeed);
// Add channel metadata
$('<title/>').text('Scraped Data RSS Feed').appendTo(channel);
$('<description/>').text('RSS feed containing scraped data').appendTo(channel);
$('<link/>').text('https://meetingpoint-brandenburg.de/').appendTo(channel);
var requestCount = urls.length; // Counter for successful requests
for (var i = 0; i < urls.length; i++) {
// Make an HTTP GET request to the current URL using the allorigins.win proxy
var proxyUrl = 'https://api.allorigins.win/get?url=' + encodeURIComponent(urls[i]);
$.ajax({
url: proxyUrl,
method: 'GET',
success: function (response) {
var responseData = JSON.parse(response.contents);
// Extract data using jQuery selectors
var titles = [];
var paragraphs = [];
// Create a temporary container element to parse the HTML response
var tempContainer = $('<div/>').html(responseData.contents);
// Iterate over the timeline elements
tempContainer.find('.timeline-item').each(function() {
var title = $(this).find('.timeline-heading').text();
var paragraph = $(this).find('.timeline-body').text();
// Skip elements with the class "small"
if (!$(this).hasClass('small')) {
titles.push(title);
paragraphs.push(paragraph);
}
});
// Create an item element
var item = $('<item/>').appendTo(channel);
// Add item metadata
$('<title/>').text(titles.join(', ')).appendTo(item); // Combine all titles into one string
...