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.

Post History

42%
+1 −2
Q&A How to scrape all thread links from a XenForo forum board? [closed]

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 st...

0 answers  ·  posted 7mo ago by ShadowsRanger‭  ·  closed 7mo ago by Karl Knechtel‭

Question javascript web-scraping
#5: Question closed by user avatar Karl Knechtel‭ · 2026-02-28T23:56:23Z (7 months ago)
#4: Post edited by user avatar ShadowsRanger‭ · 2026-02-28T18:21:24Z (7 months ago)
  • I'm trying to extract all thread links from a specific board on a XenForo forum (similar to this one: [Creative Writing](https://forum.questionablequesting.com/forums/creative-writing.19/), specifically this one: [NSFW Creative Writing](https://forum.questionablequesting.com/forums/nsfw-creative-writing.29/)), 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.
  • ```javascript
  • (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 while maintaining my logged-in session?
  • I'm trying to extract all thread links from a specific board on a XenForo forum (similar to this one: [Creative Writing](https://forum.questionablequesting.com/forums/creative-writing.19/), specifically this one: [NSFW Creative Writing](https://forum.questionablequesting.com/forums/nsfw-creative-writing.29/)), 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.
  • ```javascript
  • (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?
#3: Post edited by user avatar ShadowsRanger‭ · 2026-02-28T18:20:05Z (7 months ago)
  • I'm trying to extract all thread links from a specific board on a XenForo forum (similar to this one: [Creative Writing](https://forum.questionablequesting.com/forums/creative-writing.19/), specifically this one: [NSFW Creative Writing](https://forum.questionablequesting.com/forums/nsfw-creative-writing.29/?order=last_post_date&direction=asc&nodes[0]=-1)), 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.
  • ```javascript
  • (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 while maintaining my logged-in session?
  • I'm trying to extract all thread links from a specific board on a XenForo forum (similar to this one: [Creative Writing](https://forum.questionablequesting.com/forums/creative-writing.19/), specifically this one: [NSFW Creative Writing](https://forum.questionablequesting.com/forums/nsfw-creative-writing.29/)), 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.
  • ```javascript
  • (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 while maintaining my logged-in session?
#2: Post edited by user avatar ShadowsRanger‭ · 2026-02-28T18:19:30Z (7 months ago)
  • I'm trying to extract all thread links from a specific board on a XenForo forum (like this one: [Creative Writing](https://forum.questionablequesting.com/forums/creative-writing.19/)), but a simple script I tried stops working after the second page.
  • Why does the script fail on the second page, and how can I fix this script to reliably scrape all pages?
  • What I've tried is a JavaScript snippet that can run directly in the browser's console. It automatically clicks through all the pages of a 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.
  • ```javascript
  • (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;
  • })();
  • ```
  • I'm trying to extract all thread links from a specific board on a XenForo forum (similar to this one: [Creative Writing](https://forum.questionablequesting.com/forums/creative-writing.19/), specifically this one: [NSFW Creative Writing](https://forum.questionablequesting.com/forums/nsfw-creative-writing.29/?order=last_post_date&direction=asc&nodes[0]=-1)), 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.
  • ```javascript
  • (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 while maintaining my logged-in session?
#1: Initial revision by user avatar ShadowsRanger‭ · 2026-02-28T17:59:02Z (7 months ago)
How to scrape all thread links from a XenForo forum board?
I'm trying to extract all thread links from a specific board on a XenForo forum (like this one: [Creative Writing](https://forum.questionablequesting.com/forums/creative-writing.19/)), but a simple script I tried stops working after the second page.

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

What I've tried is a JavaScript snippet that can run directly in the browser's console. It automatically clicks through all the pages of a 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.

```javascript
(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;
})();
```