Discourse Forum Reader avatar

Discourse Forum Reader

Pricing

from $0.20 / 1,000 post reads

Go to Apify Store
Discourse Forum Reader

Discourse Forum Reader

Pricing

from $0.20 / 1,000 post reads

Rating

0.0

(0)

Developer

Adage

Adage

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

5 days ago

Last modified

Categories

Features

Limited permissions

Share

Introduction

Discourse Forum Reader reads the posts of any public Discourse forum and writes one dataset record for every post. You give it the base address of a forum and a limit. It reads the forum's public JSON pages, walks the list of latest topics, opens each topic, and writes the posts in a fixed set of ten fields. Text comes out as plain text: character references such as < are decoded first and then every tag is removed, so markup quoted inside a post is removed as well. It accepts a forum by its public host name only, and it caps the size of each post and each forum answer and the number of pages and requests in a run, as the limits below say.

It reads public topics only. It never logs in, never uses cookies, never uses a proxy and never opens a browser. It fetches from the forum you name and from no other host.

Tutorial

  1. Open the Actor's Input tab.
  2. In Forum URL, enter the base address of a public Discourse forum. Only the scheme and host are used, so a path after the host is ignored. Give the forum's public host name: an IP address, localhost, a name ending in .local, .internal or .localhost, a name with no dot, a name with an empty part (two dots in a row), and a port other than 80 or 443 are refused with BAD_INPUT before anything is fetched.
  3. In Maximum posts, enter how many post records you want. The default is 100, the smallest value is 1 and the largest is 100000.
  4. Start the run. Posts are written to the dataset as they are read, the most recently active topics first, and each topic's posts in thread order.
  5. When the run ends, open the Output tab, or export the dataset in any format the platform offers. To fetch results from code, see the dataset API on docs.apify.com.

Limits to know before you start:

  • Public topics only. A forum that has login_required switched on, or one that answers a read with 403, fails the run with a named error (LOGIN_REQUIRED or FORBIDDEN) and nothing is charged.
  • At most one request a second is sent to the forum, well inside the pace Discourse allows. When the forum answers 429 the Actor waits for the time in its Retry-After header, up to 120 seconds, then tries again, up to three times. When the header is missing it waits 10 seconds. If the fourth attempt of a request is answered 429, the Actor makes one final attempt after the time asked or 75 seconds, whichever is longer, to ride out a per-minute limit. A 429 on that final attempt fails the run with RATE_LIMITED. When the forum asks for more than 120 seconds, or when the waits for 429 answers in one run would add up to more than 240 seconds, the run fails at once with RATE_LIMITED. The request that failed is not charged, and the posts written before it stay in the dataset.
  • A topic deleted between the topic list and the read is skipped and logged.
  • The host check reads the forum address as you typed it. A host name that resolves to a private or internal address is not detected, because the Actor makes no address lookup of its own.
  • A post whose HTML body is larger than 262144 bytes is skipped and logged. It is not written and not charged, and it does not count toward Maximum posts. A forum answer larger than 8 MB fails the run with SHAPE.
  • A post listed twice in one topic is written once, even when the forum writes its id in two forms such as 1 and 01. A topic id, or the id of a post that would be written, that is not a positive whole number fails the run with SHAPE before it is used in an address or a record.
  • The run stops at Maximum posts, at the end of the forum's topic list (an empty page, or a page with no topic not seen before), after 2000 topic-list pages (page-cap), after 10 requests for each post you asked for plus 200 (request-cap), or when the pay-per-event charge limit you set for the run is reached.
  • A run therefore sends at most 10 times Maximum posts plus 200 requests to the forum, retries included: 1,200 requests for the default of 100 posts.

Pricing

This Actor uses pay-per-event pricing. One event named post is charged for each post record written to the dataset. Nothing is charged for a request, for a topic that is skipped, for a deleted or hidden post that is not written, or for a run that fails before it writes a record. The price of the event is set in the Apify Console by the Actor's owner and shown on the Actor's page. You can cap what a run may spend with the maximum charge setting of the run, and the Actor stops cleanly when that cap is reached.

Input and output examples

Input, the forum the Input tab fills in first:

{
"forumUrl": "https://discuss.python.org",
"maxPosts": 100
}

Input, a second forum, Discourse's own:

{
"forumUrl": "https://meta.discourse.org",
"maxPosts": 1000
}

Each dataset record has these ten fields:

  • forumUrl: the forum's base address.
  • topicId: the numeric id of the topic.
  • topicTitle: the topic's title.
  • postId: the numeric id of the post.
  • postNumber: the post's position in its topic, starting at 1.
  • authorUsername: the author's username.
  • createdAt: when the post was created, as an ISO 8601 timestamp.
  • text: the post body as plain text, with the HTML tags removed.
  • likeCount: the number of likes on the post, 0 when there are none.
  • postUrl: the address of the post.

One record:

{
"forumUrl": "https://meta.discourse.org",
"topicId": 1539,
"topicTitle": "Why offer Private Messaging?",
"postId": 2466,
"postNumber": 1,
"authorUsername": "singpolyma",
"createdAt": "2013-02-06T18:08:04.450Z",
"text": "Why? Isn’t this a misfeature that’s come in from existing webforum software?",
"likeCount": 0,
"postUrl": "https://meta.discourse.org/t/why-offer-private-messaging/1539/1"
}

FAQ and support

Can it read a private forum?

No. It reads what an anonymous visitor can read. If the forum requires a login, the run fails with LOGIN_REQUIRED, or with FORBIDDEN when the forum answers 403, and no post is charged.

What happens to deleted posts?

Posts deleted by their author or a moderator, hidden posts and system messages such as small-action notices are skipped. They are not written and not charged.

How fast does it read?

No faster than one request a second to the forum. Reading a topic takes one request, plus one more for each further twenty posts. A large forum therefore takes time, so set Maximum posts to what you need. When a forum answers 429, the run also waits for the time it asks, up to 120 seconds, and at least 75 seconds before its final attempt; the 429 waits of one run add up to 240 seconds at most.

Why did my run stop?

The run log ends with a summary line that names the reason. The limit reason means Maximum posts was reached. The end reason means the forum's topic list ran out. The page-cap reason means 2000 pages of the topic list were read, and the request-cap reason means the run used its allowance of requests (10 for each post asked for, plus 200); the posts written before either stay in the dataset and nothing more is charged. The charge-limit reason means the maximum charge you set for the run was reached. Any other ending is an error named at the start of its message, such as TIMEOUT, RATE_LIMITED, SHAPE or UNREACHABLE, and the posts written before it stay in the dataset.

Where do I report a problem?

Use the Issues tab on this Actor's page on the platform. Include the forum address, the input and the run's log.