Image

Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

How to scrape all thread links from a XenForo forum board? [closed]

+1
−2

Closed as not constructive by Karl Knechtel‭ on Feb 28, 2026 at 23:56

This question cannot be answered in a way that is helpful to anyone. It's not possible to learn something from possible answers, except for the solution for the specific problem of the asker.

This question was closed; new answers can no longer be added. Users with the Vote on Holds ability may vote to reopen this question if it has been improved or closed incorrectly.

I'm trying to extract all thread links from a specific board on a XenForo forum (similar to this one: Creative Writing, specifically this one: NSFW Creative Writing), but a simple script I tried stops working on the second page.

I'm using a JavaScript snippet that runs directly in the browser's console because I want to use my existing logged-in session. I would normally use Python but I don't know how to handle the login authentication from Python.

The script automatically clicks through all the pages of the forum board and collects every unique thread link it finds.

Here is the complete script. Copy, navigate to the first page of the forum board to scrape, open the browser's developer console (usually by pressing F12), paste the script, and press Enter.

(async function() {
    const allLinks = new Set();
    let currentPage = 1;
    let hasNextPage = true;

    while (hasNextPage) {
        console.log(`Scraping page ${currentPage}...`);

        // Get all thread links on current page
        const links = document.querySelectorAll('a[href*="/threads/"]');
        links.forEach(link => {
            if (link.href && !link.href.includes('#') && link.href.includes('/threads/')) {
                allLinks.add(link.href);
            }
        });

        // Check for next page button - XenForo usually uses rel="next"
        const nextButton = document.querySelector('a.pageNav-jump--next, a[rel="next"]');

        if (nextButton) {
            nextButton.click();
            // Wait for the next page to load
            await new Promise(resolve => setTimeout(resolve, 5000));
            currentPage++;
        } else {
            hasNextPage = false;
        }
    }

    // Display and copy results
    console.log(`Finished! Found ${allLinks.size} unique thread links.`);
    const linksArray = Array.from(allLinks);
    const linksText = linksArray.join('\n');

    // Copy to clipboard
    try {
        await navigator.clipboard.writeText(linksText);
        console.log('✅ All links have been copied to your clipboard!');
    } catch (err) {
        console.error('❌ Failed to copy links to clipboard:', err);
        // Fallback: log the links to the console
        console.log('Links found:', linksArray);
    }

    return linksArray;
})();

Why does the script fail on the second page, and how can I fix this script to reliably scrape all pages and get all the story links?

History

2 comment threads

Seems answerable to me! (1 comment)
About debugging (2 comments)