# Python Web Scraping taste of a data engineer who wants scrapers that are polite and boring to maintain
- Look for an official API, a sitemap, an RSS feed or the JSON endpoint the page itself calls before parsing any HTML. Confidence: 0.90
- Read the site's terms and robots.txt first, and skip sources that clearly forbid automated access. Confidence: 0.85
- Use httpx with a shared client, connection pooling, timeouts on every request and HTTPhttps://www.aitopic.com/2 when the site supports it. Confidence: 0.85
- Send an honest User-Agent with a contact URL or email instead of pretending to be a browser. Confidence: 0.75
- Rate-limit per domain (for example one request per second by default) and add jittered exponential backoff on 429 and 5xx responses. Confidence: 0.90
- Respect Retry-After headers and stop the run when error rates spike instead of hammering a struggling site. Confidence: 0.85
- Parse HTML with selectolax or lxml and CSS selectors; reach for BeautifulSoup only for small scripts or very broken markup. Confidence: 0.70
- Use Playwright only when content truly needs JavaScript, and block images, fonts and trackers to keep it fast. Confidence: 0.80
- Prefer stable hooks like ids, data attributes and JSON-LD over long positional XPath or styling class names. Confidence: 0.85
- Save the raw response (HTML or JSON) with its URL and fetch time before parsing, so you can re-parse without re-fetching. Confidence: 0.85
- Keep fetching and parsing as separate steps with parser functions that take a string and return plain data, easy to unit test. Confidence: 0.85
- Write parser tests against saved fixture pages and refresh the fixtures when the site changes. Confidence: 0.80
- Validate every scraped record with Pydantic and send records that fail validation to a reject file instead of dropping them silently. Confidence: 0.85
- Normalize prices, dates, currencies and whitespace at parse time into typed fields, keeping the original text alongside. Confidence: 0.75
- Make runs resumable and idempotent: track visited URLs and upsert records by a stable natural key. Confidence: 0.85
- Use conditional requests (ETag, If-Modified-Since) and skip pages that have not changed since the last run. Confidence: 0.70
- Use asyncio with a bounded semaphore for concurrency, never an unbounded gather over thousands of URLs. Confidence: 0.80
- Reach for Scrapy when a project crawls many sites or needs pipelines and scheduling, not for a one-page script. Confidence: 0.65
- Never scrape behind a login or collect personal data unless you have clear permission and a reason to keep it. Confidence: 0.90
- Alert when the record count or the share of empty fields drops sharply; that is how you notice the layout changed. Confidence: 0.85
- Log each request with URL, status code, duration and retry count in structured form. Confidence: 0.75
- Pin dependencies and run scrapers on a schedule in CI or a small container, not from someone's laptop cron. Confidence: 0.75
Comments & Questions (0)
No comments yet
Be the first to comment!