Skip to content

fix: WestSuffolkCouncil - send a User-Agent header#1955

Open
InertiaUK wants to merge 5 commits intorobbrad:masterfrom
InertiaUK:fix/west-suffolk-user-agent
Open

fix: WestSuffolkCouncil - send a User-Agent header#1955
InertiaUK wants to merge 5 commits intorobbrad:masterfrom
InertiaUK:fix/west-suffolk-user-agent

Conversation

@InertiaUK
Copy link
Copy Markdown

What this changes

The MyWestSuffolk.aspx?action=SetAddress&UniqueId=... endpoint is served by IIS and now returns a 404 page (body 1.2KB, title "404 - File or directory not found.") to any request without a User-Agent header. Adding a realistic Chrome UA restores the full 57KB property page and the existing parser finds the bin collection panel correctly.

Change

Single one-liner: pass a headers={"User-Agent": "..."} to requests.get.

No parser changes needed — the existing panel_search helper still finds div.atPanelData under the Bin collection days <h4> once the response is the real one.

Test

Verified against UPRN 10009739960:

{
  "bins": [
    { "type": "Black bin", "collectionDate": "16/04/2026" },
    { "type": "Blue bin",  "collectionDate": "22/04/2026" },
    { "type": "Brown bin", "collectionDate": "22/04/2026" }
  ]
}

Torridge's SOAP API changed its response from explicit dates ("Mon 14 Apr")
to relative phrases ("Tomorrow then every Mon", "Today then every Tue")
with an embedded calendar table. The old regex-based parser returned empty
because it expected the old format.

The rewritten parser handles Today/Tomorrow/weekday-name phrases, falls back
to the old explicit format if it reappears, and gracefully skips "No X
collection for this address" entries.
The Wyre bin collection page now includes a 'Download calendar' box
among the .boxed divs. This box has no h3.bin-collection-tasks__heading,
which caused the scraper to crash on .text access.

Changes:
- Skip boxes missing the heading or content container
- Use regex to extract the bin name from 'Your next X collection'
- Collapse whitespace on the date text before strptime (p tags produced
  multi-whitespace runs after .text)
- Roll year forward only when the computed date is in the past, instead
  of only handling the December->January edge case
…e results

The checkyourbinday page is now:
- Gated by Cloudflare Turnstile (requires non-headless UC)
- Using WASTECOLLECTIONCALENDARV7_* element IDs (was V5)
- Rendering collection dates inline as .gi-summary-blocklist__row
  divs after address selection — no separate NEXT/submit step

Changes:
- Update all element IDs from V5 to V7
- Add Cloudflare challenge wait loop (up to 50s)
- Dismiss cookie consent before interaction (was blocking button clicks)
- Replace old table-based parsing with .gi-summary-blocklist__row scraping
- Use Select.select_by_visible_text with stale-retry instead of manual
  option.click() loop (which crashed on AJAX re-renders)
- Remove the smart_select_address helper's dead fuzzy/strict split
…anner

Stockton's AchieveForms form name changed from LOOKUPBINDATESBYADDRESSSKIPOUTOFREGION
to LOOKUPBINDATESBYADDRESSSKIPOUTOFREGIONV2, so every element ID needed
the V2 suffix added. Also added a cookie-banner dismissal step — the
banner was covering the search button and intercepting clicks.
The MyWestSuffolk.aspx IIS endpoint returns a 404 page to requests
without a User-Agent header. Adding a realistic Chrome UA restores the
full response (57KB), letting the existing parser pick up the bin
collection panel correctly.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

Warning

Rate limit exceeded

@InertiaUK has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 32 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 32 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7847e8ef-f130-4ec5-821a-4dae0c92a944

📥 Commits

Reviewing files that changed from the base of the PR and between 60bd3cc and fac7731.

📒 Files selected for processing (5)
  • uk_bin_collection/uk_bin_collection/councils/ChichesterDistrictCouncil.py
  • uk_bin_collection/uk_bin_collection/councils/StocktonOnTeesCouncil.py
  • uk_bin_collection/uk_bin_collection/councils/TorridgeDistrictCouncil.py
  • uk_bin_collection/uk_bin_collection/councils/WestSuffolkCouncil.py
  • uk_bin_collection/uk_bin_collection/councils/WyreCouncil.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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