how to get raw content with rss?
- User
how to get raw content with rss?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
how to get raw content with rss?
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To retrieve the raw content (full article text) using RSS, you typically need to parse the RSS feed and then extract the full content from each entry. Here's a step-by-step guide:
<content:encoded> (e.g., WordPress)<description> (may contain summaries or full HTML)<atom:content><item>
<title>Article Title</title>
<link>https://example.com/article</link>
<description>Short summary...</description>
<content:encoded>
<![CDATA[<p>Full article <b>HTML content</b> here...</p>]]>
</content:encoded>
</item>
feedparser + beautifulsoup4Install libraries:
pip install feedparser beautifulsoup4
Example Code:
import feedparser
from bs4 import BeautifulSoup
# Parse RSS feed
feed_url = "https://example.com/feed.rss"
feed = feedparser.parse(feed_url)
for entry in feed.entries:
# Try to get full content from common fields
raw_content = entry.get("content", [{}])[0].get("value") # For <content:encoded>
if not raw_content:
raw_content = entry.get("description") # Fallback to description
# Clean HTML to get plain text (optional)
if raw_content:
soup = BeautifulSoup(raw_content, "html.parser")
plain_text = soup.get_text()
else:
plain_text = "No content found."
print(f"Title: {entry.title}")
print(f"Raw Text: {plain_text}\n---")
If the RSS feed lacks full content, scrape the article URL:
import requests
# Scrape article URL from RSS entry
def scrape_article(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
# Site-specific extraction (customize per website):
article = soup.find("article") or soup.find(class_="post-content")
return article.get_text() if article else "Content not found."
# Use in the loop above:
if not raw_content:
plain_text = scrape_article(entry.link)
robots.txt: Check if scraping is allowed.content:encoded, atom:content). Inspect the feed’s XML structure first.<![CDATA[...]]>; libraries like feedparser handle this automatically.Check the RSS structure by viewing the feed source in a browser. Look for:
<content:encoded>Full HTML content here...</content:encoded>
<!-- OR -->
<description>Full content or summary...</description>
If the feed doesn’t include full content, contact the publisher or use web scraping ethically.