Loading...
Loading...
Compare original and translation side by side
references/practices-catalog.md| Concern | Chapters to Apply |
|---|---|
| Basic page fetching and parsing | Ch 1: urllib/requests, BeautifulSoup setup, first scraper |
| Finding elements in HTML | Ch 2: find/findAll, CSS selectors, navigating DOM trees, regex, lambda filters |
| Crawling within a site | Ch 3: Following links, building crawlers, breadth-first vs depth-first |
| Crawling across sites | Ch 4: Planning crawl models, handling different site layouts, normalizing data |
| Framework-based scraping | Ch 5: Scrapy spiders, items, pipelines, rules, CrawlSpider, logging |
| Saving scraped data | Ch 6: CSV, MySQL/database storage, downloading files, sending email |
| Non-HTML documents | Ch 7: PDF text extraction, Word docs, encoding handling |
| Data cleaning | Ch 8: String normalization, regex cleaning, OpenRefine, UTF-8 handling |
| Text analysis on scraped data | Ch 9: N-grams, Markov models, NLTK, summarization |
| Login-protected pages | Ch 10: POST requests, sessions, cookies, HTTP basic auth, handling tokens |
| JavaScript-rendered pages | Ch 11: Selenium WebDriver, headless browsers, waiting for Ajax, executing JS |
| Working with APIs | Ch 12: REST methods, JSON parsing, authentication, undocumented APIs |
| Images and OCR | Ch 13: Pillow image processing, Tesseract OCR, CAPTCHA handling |
| Avoiding detection | Ch 14: User-Agent headers, cookie handling, timing/delays, honeypot avoidance |
| Testing scrapers | Ch 15: unittest for scrapers, Selenium-based testing, handling site changes |
| Parallel scraping | Ch 16: Multithreading, multiprocessing, thread-safe queues |
| Remote/anonymous scraping | Ch 17: Tor, proxies, rotating IPs, cloud-based scraping |
| Legal and ethical concerns | Ch 18: robots.txt, Terms of Service, CFAA, copyright, ethical scraping |
references/practices-catalog.md| 关注点 | 适用章节 |
|---|---|
| 基础页面获取与解析 | 第1章:urllib/requests、BeautifulSoup配置、第一个爬虫 |
| HTML元素定位 | 第2章:find/findAll、CSS选择器、DOM树导航、正则表达式、lambda过滤器 |
| 站点内爬行 | 第3章:链接追踪、爬虫构建、广度优先vs深度优先 |
| 跨站点爬行 | 第4章:爬虫模型规划、多站点布局处理、数据标准化 |
| 框架式爬取 | 第5章:Scrapy Spiders、Items、Pipelines、Rules、CrawlSpider、日志 |
| 爬取数据存储 | 第6章:CSV、MySQL/数据库存储、文件下载、邮件发送 |
| 非HTML文档处理 | 第7章:PDF文本提取、Word文档、编码处理 |
| 数据清洗 | 第8章:字符串标准化、正则清洗、OpenRefine、UTF-8处理 |
| 爬取数据的文本分析 | 第9章:n-grams、马尔可夫模型、NLTK、文本摘要 |
| 登录保护页面处理 | 第10章:POST请求、会话、Cookie、HTTP基础认证、令牌处理 |
| JavaScript渲染页面处理 | 第11章:Selenium WebDriver、无头浏览器、Ajax等待、JS执行 |
| API调用 | 第12章:REST方法、JSON解析、认证、未公开API |
| 图片与OCR | 第13章:Pillow图像处理、Tesseract OCR、验证码处理 |
| 避免被检测 | 第14章:User-Agent请求头、Cookie处理、请求延迟、蜜罐规避 |
| 爬虫测试 | 第15章:unittest测试框架、Selenium测试、站点变更处理 |
| 并行爬取 | 第16章:多线程、多进程、线程安全队列 |
| 远程/匿名爬取 | 第17章:Tor、代理、IP轮换、云爬虫 |
| 法律与伦理 | 第18章:robots.txt、服务条款、CFAA、版权、伦理爬取 |
User: "Scrape product listings from an e-commerce category page"
Apply: Ch 1 (fetching pages), Ch 2 (parsing product elements),
Ch 3 (pagination/crawling), Ch 6 (storing to CSV/DB)
Generate:
- requests + BeautifulSoup scraper
- CSS selector-based product extraction
- Pagination handler following next-page links
- CSV or database storage with schema
- Rate limiting and error handlingUser: "Extract data from a React single-page application"
Apply: Ch 11 (Selenium, headless browser), Ch 2 (parsing rendered HTML),
Ch 14 (avoiding detection), Ch 15 (testing)
Generate:
- Selenium WebDriver with headless Chrome
- Explicit waits for dynamic content loading
- JavaScript execution for scrolling/interaction
- Data extraction from rendered DOM
- Headless browser configurationUser: "Scrape data from a site that requires login"
Apply: Ch 10 (forms, sessions, cookies), Ch 14 (headers, tokens),
Ch 6 (data storage)
Generate:
- Session-based login with CSRF token handling
- Cookie persistence across requests
- POST request for form submission
- Authenticated page navigation
- Session expiry detection and re-loginUser: "Build a crawler to scrape thousands of pages from multiple domains"
Apply: Ch 5 (Scrapy framework), Ch 4 (crawl models),
Ch 16 (parallel scraping), Ch 14 (avoiding blocks)
Generate:
- Scrapy spider with item definitions and pipelines
- CrawlSpider with Rule and LinkExtractor
- Pipeline for database storage
- Settings for concurrent requests, delays, user agents
- Middleware for proxy rotationUser: "Scrape product listings from an e-commerce category page"
Apply: Ch 1 (fetching pages), Ch 2 (parsing product elements),
Ch 3 (pagination/crawling), Ch 6 (storing to CSV/DB)
Generate:
- requests + BeautifulSoup scraper
- CSS selector-based product extraction
- Pagination handler following next-page links
- CSV or database storage with schema
- Rate limiting and error handlingUser: "Extract data from a React single-page application"
Apply: Ch 11 (Selenium, headless browser), Ch 2 (parsing rendered HTML),
Ch 14 (avoiding detection), Ch 15 (testing)
Generate:
- Selenium WebDriver with headless Chrome
- Explicit waits for dynamic content loading
- JavaScript execution for scrolling/interaction
- Data extraction from rendered DOM
- Headless browser configurationUser: "Scrape data from a site that requires login"
Apply: Ch 10 (forms, sessions, cookies), Ch 14 (headers, tokens),
Ch 6 (data storage)
Generate:
- Session-based login with CSRF token handling
- Cookie persistence across requests
- POST request for form submission
- Authenticated page navigation
- Session expiry detection and re-loginUser: "Build a crawler to scrape thousands of pages from multiple domains"
Apply: Ch 5 (Scrapy framework), Ch 4 (crawl models),
Ch 16 (parallel scraping), Ch 14 (avoiding blocks)
Generate:
- Scrapy spider with item definitions and pipelines
- CrawlSpider with Rule and LinkExtractor
- Pipeline for database storage
- Settings for concurrent requests, delays, user agents
- Middleware for proxy rotationreferences/review-checklist.mdreferences/review-checklist.mdundefinedundefinedundefinedundefinedreferences/practices-catalog.mdreferences/review-checklist.mdreferences/practices-catalog.mdreferences/review-checklist.md