this post was submitted on 11 Jul 2023
21 points (95.7% liked)

Selfhosted

40405 readers
849 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
21
Can FreshRSS Crawl? (lemmy.dbzer0.com)
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/selfhosted
 

I recently started up FreshRSS in my docker environment. I was super excited about the web scraping feature.

Now that I'm setting it up, it looks like that it is able to scrape single web pages, but I am unable to figure out how to get it to crawl into the actual article to scrape the full content.

Is anyone aware of how to do this. For example, runescape.com/m=news/ This page has a list of articles with a thumbnail, title, category, date, and a short description of the article. Would it be possible for FreshRSS to crawl into the article link and scrape the contents within?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 1 year ago (2 children)

It can be done directly in FreshRSS and I've done it successfully with a few websites, though the process is fairly involved. Here's a starting point, from the FreshRSS documentation:

https://freshrss.github.io/FreshRSS/en/users/11_website_scraping.html

This blog post (also linked in the FreshRSS docs above) proved extremely useful as an example on how to get started:

https://danq.me/2022/09/27/freshrss-xpath/

Good luck!

[–] [email protected] 1 points 1 year ago

Thanks a ton for those links

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (2 children)

Before you go reading all that, out of curiosity I looked around the RuneScape site and found the News RSS feed here:

https://secure.runescape.com/m=news/latest_news.rss

That feed contains only titles, thumbnails and a very small preview of each article. However, with FreshRSS you don't need to do scraping/crawling at all to get full articles from limited RSS feeds like this one. Here's what you do:

  1. Subscribe to the RSS feed in FreshRSS as you normally would.
  2. Go to Subscription Management and find the settings for the RuneScape feed.
  3. In the Advanced section of the feed settings, find the item called "Article CSS selector on original website", and write .c-news-article__content in that text box. You can click on the button next to the text box to preview the full article that FreshRSS will retrieve.
  4. Click Submit to save the changes, and then go to the bottom of the feed settings and click Reload articles so that FreshRSS populates the feed with a few full articles.

That should do it. The CSS selector essentially tells FreshRSS which section of the full article's HTML/CSS is the body of the article, which FreshRSS then uses to populate the body of the RSS feed.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

Thank you so much! This worked out fantastically and it also looks great in the feed. I don't know how you figured this stuff out but I need to get learned up on this!

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

Would you be able to help me on Humble Bundles feed?

I am using the RSS Feed:

When trying to use the same process you did in the RuneScape feed, it didn't seem to work.

I go to the full articles, I found that the content is listed in the Class site-content container clearfix. Attempting to add .site-content container clearfix in the Article CSS selector on original website area. It says The selector didn’t match anything. As a fallback the original feed text will be displayed instead.

Could you tell me what I'm doing wrong?

[–] [email protected] 2 points 1 year ago (1 children)

Using .site-content container clearfix didn't work because those are actually three separate CSS classes, so you'd have to use only one - for example .site-content. However, it looks like .site-content is too big, as it includes the website's sidebar as well. You may already know this but in Firefox and Chrome you can right click anywhere on the website and use the Inspect option to look at the source, and clicking on a section of the source highlights the corresponding section of the website and this will help you find exactly the CSS class you're looking for. I did this on a couple articles from Humble Bundle and found a couple of options:

  • .post: This includes only the content of the post, excluding the title and the image.
  • .site-main: This includes the title, author, image and the content.

Another useful tool in FreshRSS I forgot to mention is "CSS selector of the elements to remove". You can use it to remove certain section from the full article, I'd recommend removing .sharedaddy and .entry-footer (the sharing links at the end of the article), and also .entry-header if you use .site-main as the CSS selector for the full article (.entry-header is the title of the article, but FreshRSS already fetches it from the RSS feed so you don't need it in the body of the article as well). You can remove multiple sections by using a comma-separated list of CSS classes to remove:

.entry-header, .sharedaddy, .entry-footer

[–] [email protected] 1 points 1 year ago (1 children)

Thank you again :). From your explanation, I think I have a good grasp on how to identify the proper CSS elements now.

Have a wonderful day!

[–] [email protected] 1 points 1 year ago

No problem! FreshRSS really is amazing so I'm happy to help and spread the love.