Skip to content

Fix stackoverflow.com main page retrieval failing on Cloudflare challenge - #442

Merged
benoit74 merged 3 commits into
mainfrom
benoit74/stackoverflow.com-is-failing-on-main-page-retrie
Oct 22, 2026
Merged

benoit74 merged 3 commits into
mainfrom
benoit74/stackoverflow.com-is-failing-on-main-page-retrie

Conversation

@benoit74

@benoit74 benoit74 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • stackoverflow.com's homepage redirects to /questions, which is behind a Cloudflare bot challenge, causing _get_site_details() to fail and the whole scrape with it (stackoverflow.com is failing on main page retrieval #441).
  • _get_site_details() now fetches /help instead of the homepage — it isn't guarded and carries the same site-wide title/header/CSS/favicon/mathjax/highlight information on every domain tested.
  • site_title is now read from the page-independent <meta property="og:site_name"> tag instead of <title>, which is more robust (page-dependent <title> would otherwise give odd results, e.g. "Newest Questions - Stack Overflow" instead of "Stack Overflow").
  • Investigation details and the options considered are in the issue comments on stackoverflow.com is failing on main page retrieval #441.

…enge

The homepage of stackoverflow.com redirects to /questions, which is
behind a Cloudflare bot challenge. Retry on /help in that case, which
carries the same site-wide title/header/CSS/favicon/mathjax/highlight
information. The homepage is still tried first since /help redirects
to the parent site on meta.* domains.

Fixes #441
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.62%. Comparing base (6f7eafa) to head (8751c66).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/sotoki/scraper.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #442   +/-   ##
=======================================
  Coverage   16.62%   16.62%           
=======================================
  Files          26       26           
  Lines        2460     2460           
  Branches      318      318           
=======================================
  Hits          409      409           
  Misses       2025     2025           
  Partials       26       26           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benoit74 benoit74 self-assigned this Oct 22, 2026
The homepage-first/help-fallback split was guarding against meta.*
domains, which sotoki doesn't scrape in practice. Always using /help
is simpler and just as safe.
@benoit74
benoit74 merged commit a5beb11 into main Oct 22, 2026
5 checks passed
@benoit74
benoit74 deleted the benoit74/stackoverflow.com-is-failing-on-main-page-retrie branch October 22, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant