[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-post-web-scraping-yellow-pages-en":3},{"post":4,"faq":33,"faqLdJson":48,"faqLdJsonScript":67,"alternatePaths":68,"recommendations":70,"contentLocale":20},{"authors":5,"custom_excerpt":13,"excerpt":13,"feature_image":14,"featured":15,"id":16,"meta_description":13,"meta_title":17,"og_description":8,"og_image":8,"og_title":8,"primary_author":18,"primary_tag":19,"published_at":22,"reading_time":23,"slug":24,"status":25,"tags":26,"title":17,"twitter_description":8,"twitter_image":8,"twitter_title":31,"updated_at":22,"visibility":21,"lexical":32},[6],{"bio":7,"facebook":8,"instagram":8,"linkedin":8,"location":9,"name":10,"profile_image":11,"slug":12,"tiktok":8,"twitter":8,"website":8,"youtube":8},"A Columnist at Rola IP, Chloe is deeply curious about digital marketing and search engine logic. Outside of work, she enjoys experimenting with web layout tools, photography, and image processing.",null,"Chloe是Rola IP的专栏作者。生活中，她对数字营销和搜索引擎背后的逻辑充满好奇。除了研究各种实用的网页排版工具，她还热爱摄影与图像处理。","Chloe Sun","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FPixPin_2026-08-13_11-09-19.png","chloe","Learn to scrape Yellow Pages with Python. Master pagination, rate limits, page validation, and test with a local HTML demo.","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F10\u002FWeb-Scraping-Yellow-Pages-article-cover-image.webp",false,"6ad1df8a4956c90001bf18ea","Web Scraping Yellow Pages with Python: Workflow and HTML Demo",{"bio":7,"facebook":8,"instagram":8,"linkedin":8,"location":9,"name":10,"profile_image":11,"slug":12,"tiktok":8,"twitter":8,"website":8,"youtube":8},{"description":8,"feature_image":8,"name":20,"slug":20,"visibility":21},"en","public","2026-10-16T09:16:18.000Z",23,"web-scraping-yellow-pages","published",[27,28],{"description":8,"feature_image":8,"name":20,"slug":20,"visibility":21},{"description":8,"feature_image":8,"name":29,"slug":30,"visibility":21},"教程","guides","Web Scraping Yellow Pages","{\"root\":{\"children\":[{\"type\":\"markdown\",\"version\":1,\"markdown\":\"## TL;DR:\\nThis guide explains how to adapt a Python web scraping workflow to Yellow Pages pages that you are authorized to access. It covers permission checks, URL and pagination inspection, response handling, selector mapping, rate limits, deduplication, and CSV export. The included project uses fictional local HTML for reproducible testing and produces 10 businesses from 12 cards.\\n\\nAll code and sample inputs are included on the end of this page: Appendix A contains the three Python programs, Appendix B contains the URL lists and run order, and Appendix C contains the three HTML pages. Save each code block under its stated filename. The sample businesses, addresses, and phone numbers are fictional; the detail URLs use `example.com`.\\n\\n## What Can You Analyze with Yellow Pages Business Data?\\n\\nBusiness-directory analysis can help compare observed listings by location or category, identify repeated records, and find missing contact fields. Retain sources so that a colleague can trace each exported record back to its input page.\\n\\n| Field | Source in the sample | Use |\\n| --- | --- | --- |\\n| business_id \u002F name | Card attribute and title | Identify records and detect duplicates |\\n| category | Category label | Count listings by category |\\n| city \u002F state \u002F address | Location fields | Group locations without mixing same-name cities across states |\\n| phone_raw \u002F phone | Original text and normalized value | Retain the input while checking formatting |\\n| listing_url | Business-name link | Preserve the supplied detail link |\\n| sponsored \u002F source_file | Card attribute and downloaded filename | Identify sample sponsored cards and trace input files |\\n\\nThese counts describe the input pages, not market size or market share. Search filters, directory coverage, advertising placement, and collection time can all affect a real directory sample.\\n\\n## Web Scraping Yellow Pages: A Python Guide\\n\\nThis guide has two parts: an authorized real-site adaptation workflow and a local reproducible project. The local project has three programs—a local HTTP server, a page downloader, and an HTML parser—so a network failure can be distinguished from a field-mapping problem.\\n\\n### Before You Request a Real Page\\n\\nUse this sequence for a real directory source that you are permitted to access:\\n\\n1. Confirm the site's terms, robots guidance, API availability, and the permitted collection and reuse scope. Do not bypass login, CAPTCHA, access controls, or rate limits.\\n2. Record the exact search URL, pagination method, language or location filters, and retrieval date. Begin with one page and a low request rate.\\n3. Send a request with explicit connection and read timeouts. Inspect the status code and content type before parsing; a 200 response may contain a login, verification, or JavaScript shell instead of listings.\\n4. Save the permitted HTML and a manifest containing the requested URL, final URL, status, timestamp, and content hash. Inspect the saved page to map the current card and field selectors.\\n5. Validate a small sample of names, locations, phone text, and detail links manually before adding pagination. Stop the batch on 403 or 429 and follow any documented retry guidance.\\n6. Keep raw fields and source references, then deduplicate and export only the data needed for the authorized purpose. The local project below demonstrates these checks without contacting a live directory.\\n\\n![Local sample workflow: three HTML pages become 12 cards, 10 retained businesses, and five CSV reports](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F10\u002Frevised-workflow.webp)\\nFigure 1 | Workflow diagram for the supplied fictional dataset.\\n\\n### Step 1 | Prepare the Environment and Project\\n\\n**Verified on October 14, 2026:** Windows 10 build 19045, Python 3.14.4, Requests 2.33.1, and BeautifulSoup 4.14.3. Validation used the supplied fictional HTML over localhost, one request at a time, with no proxy. The expected extraction totals appear in Step 4, and Step 6 includes a reproducible HTTP 429 check.\\n\\nCreate a folder named `project` with an `html` subfolder. Save the three programs from Appendix A in `project`, the two URL lists from Appendix B in `project`, and the three HTML blocks from Appendix C in `project\u002Fhtml`. Open a terminal in `project` and create a virtual environment. The verified installation uses Python 3.14.4; compatibility with other versions is not part of this example's test results.\\n\\n```powershell\\n# Windows PowerShell\\npython -m venv .venv\\n.\\\\.venv\\\\Scripts\\\\python.exe -m pip install requests==2.33.1 beautifulsoup4==4.14.3\\n```\\n\\nOn macOS or Linux, create the environment with `python3 -m venv .venv`, activate it with `source .venv\u002Fbin\u002Factivate`, and install with `python -m pip install requests==2.33.1 beautifulsoup4==4.14.3`. The remaining examples use `python`; in PowerShell, use `.\\\\.venv\\\\Scripts\\\\python.exe` in place of `python` to select the project environment without changing execution policy.\\n\\n```text\\nproject\u002F\\n  serve_pages.py\\n  fetch_pages.py\\n  yellowpages_pipeline.py\\n  urls.txt\\n  rejected_urls.txt\\n  html\u002F\\n    approved_directory_page_1.html\\n    approved_directory_page_2.html\\n    approved_directory_page_3.html\\n```\\n\\n### Step 2 | Request Pages and Save HTML\\n\\nStart the server in one terminal, then run the downloader in another. Keep both terminals in the `project` folder.\\n\\n```bash\\n# Terminal 1\\npython serve_pages.py --port 8765\\n\\n# Terminal 2\\npython fetch_pages.py --urls urls.txt --origin http:\u002F\u002F127.0.0.1:8765 --out-dir downloaded\\n```\\n\\nThe URL file contains three local page addresses. The downloader validates every URL against the chosen origin before making any request, disables automatic redirects, and uses a one-second interval between requests. Its `(5, 15)` timeout specifies connection and read timeouts, not a total batch deadline. Set `--delay` to the interval appropriate for a permitted source; the default is a demonstration setting, not a site's rate-limit allowance.\\n\\nOnly HTTP 200 HTML responses are saved. Streaming reads stop when the decoded body would exceed 2,000,000 bytes; an oversized page is not saved. This is an application-level body limit, not an exact cap on network bytes. HTTP 403 or 429 ends the current batch after recording the response, and no automatic retry is attempted.\\n\\nEach run requires a new or empty output directory. For a second run, use a different directory name, such as `--out-dir downloaded-2`. The parser uses the successful filenames in that run's `http_manifest.csv`, avoiding unrelated old HTML files.\\n\\nThe manifest records the requested and final URL, status, Content-Type, saved filename, SHA-256 hash, and retrieval timestamp. Compare the saved file's hash with the recorded value when checking whether an input has changed. The hash alone does not establish the authenticity of the source.\\n\\n### Step 3 | Parse Business Fields\\n\\nThe sample uses `article.result` for business cards, `.business-name` for names, `.categories` for category labels, `.locality` for city\u002Fstate, `.phones` for phone text, and `.street-address` for addresses. These are sample selectors, not a claim about the current YellowPages.com layout.\\n\\n![Browser developer tools showing a fictional business card and its name, phone, and location selectors](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F10\u002Flocal-listing-dom.webp)\\n\\nFigure 2 | Inspecting the local fictional page to map a listing container and its fields. These are sample selectors, not verified YellowPages.com selectors.\\n\\n```python\\nfor card in soup.select(\\\"article.result\\\"):\\n    name = field(card, \\\".business-name\\\")\\n    category = field(card, \\\".categories\\\")\\n    location = field(card, \\\".locality\\\")\\n    phone_raw = field(card, \\\".phones\\\")\\n    phone = normalize_phone(phone_raw)\\n```\\n\\nThe helper functions are included in the complete parser in Appendix A. For another parsing walkthrough, see this [BeautifulSoup Python example](https:\u002F\u002Frola-ip.co\u002Fblog\u002Fbeautifulsoup-python-example\u002F).\\n\\nPhone normalization formats ten-digit numbers as `AAA-BBB-CCCC` and removes a leading `1` from eleven-digit inputs. It preserves the original text in `phone_raw`; values outside that pattern get an empty normalized field. This is formatting, not validation that a number is assigned or reachable, and it does not handle extensions or international numbering plans.\\n\\nWhen adapting to another permitted source, inspect a saved page, update the card and field selectors, resolve relative detail links against the page URL if needed, and verify a small sample manually. Supply the permitted pagination URLs in the input file; this example does not discover a live site's pagination automatically. An error is raised only when no matching business cards are found across all selected input files; an empty individual page should be reviewed separately.\\n\\n### Step 4 | Deduplicate and Export CSV\\n\\n```bash\\npython yellowpages_pipeline.py --input-dir downloaded --out-dir results\\n```\\n\\nThe parser uses a business ID when one is present. Otherwise, it combines normalized name, city, state, and street address. Records with an incomplete fallback identity remain separate for manual review, rather than being merged on name alone. Missing names or cities are excluded with a reason. Stable IDs are assumed to identify records within one source; combining multiple directories requires a source namespace or a reviewed matching strategy.\\n\\nThe verified sample yields:\\n\\n```text\\nHTML files: 3 | Cards: 12\\nUnique businesses saved: 10\\nDuplicates removed: 2\\nMissing phone: 1\\n```\\n\\n![Local Python run saving three HTML pages and exporting ten businesses from twelve cards with two duplicates removed](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F10\u002Flocal-fetch-export.webp)\\nFigure 3 | Actual localhost retrieval and CSV export for the three fictional pages in Appendix C. The screenshot uses separate screenshot output directories; the counts match the example above.\\n\\n| Output file | Contents | Check |\\n| --- | --- | --- |\\n| businesses.csv | Retained business fields, including raw phone text | 10 records in this sample |\\n| excluded.csv | Duplicate or incomplete records and reasons | 2 duplicates in this sample |\\n| categories.csv | Count per category | Counts sum to 10 |\\n| cities.csv | Count per city and state | Same-name cities in different states remain separate |\\n| city_category.csv | Count per city, state, and category | Counts sum to 10 |\\n\\nAll five files use UTF-8 with a byte-order mark and include column headers. `source_file` joins an exported business to the manifest's `saved_file`, which contains its retrieval URL and timestamp. The supplied duplicate policy retains the first matching record; it does not reconcile conflicting values across duplicate cards.\\n\\n### Step 5 | Check Counts in a Spreadsheet\\n\\nImport `results\u002Fbusinesses.csv` using Excel's **Data → From Text\u002FCSV**, or open it in LibreOffice Calc. Import phone and identifier columns as text. For untrusted real-world inputs, treat text beginning with formula characters as text during import; this example writes the extracted values without spreadsheet-specific formula sanitization.\\n\\n![Ten fictional business records exported to CSV, including raw phone text, normalized phones, city, and state](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F10\u002Flocal-businesses-csv.webp)\\nFigure 4 | The ten retained fictional records. One record has no normalized phone number; raw values are retained for review.\\n\\nTo build a pivot table from `city_category.csv`, use `state` and `city` as row fields, `category` as the column field, and **Sum of count** as the value. Counting the rows instead would count summary groups, not businesses.\\n\\nThe expected category totals are shown below. They sum to the ten retained businesses, not to all twelve input cards.\\n\\n| Category | Retained businesses |\\n| --- | --- |\\n| Auto Repair | 2 |\\n| Dentists | 3 |\\n| Electricians | 2 |\\n| Plumbers | 3 |\\n\\nCheck `excluded.csv` for two duplicate records and `businesses.csv` for one empty normalized phone field. Compare a few exported names, addresses, and raw phone values with the HTML in Appendix C.\\n\\n### Step 6 | Test Failure Handling\\n\\nWith the demonstration server still running, you can also inspect the stop behavior directly:\\n\\n```bash\\npython fetch_pages.py --urls rejected_urls.txt --origin http:\u002F\u002F127.0.0.1:8765 --out-dir rejected-run\\n```\\n\\nThat list contains a 429 URL followed by a normal page. The manifest contains only the first request, with `stopped_http_429`; the second URL is not requested. Keep this failure demonstration separate from the three-page extraction run.\\n\\n| Symptom | What to check | Program behavior or next action |\\n| --- | --- | --- |\\n| HTTP 403 | Permission, authentication, source requirements | Record response and stop batch; resolve access before a new run |\\n| HTTP 429 | Source rate limits and any Retry-After guidance | Record response and stop batch; reschedule only at a permitted frequency |\\n| HTTP 503 or 404 | Availability or incorrect URL | Record and skip that response; inspect before retrying |\\n| HTTP redirect | Intended destination and permission scope | Do not follow automatically; review the URL |\\n| HTTP 200 but no business cards | Body content, rendering, selectors | Parser raises an error when no cards are found |\\n| Existing output directory | Earlier run files | Choose a fresh output directory |\\n| Empty normalized phone | Raw text and numbering format | Preserve `phone_raw` and review manually |\\n\\nFor additional context on [503 Service Unavailable](https:\u002F\u002Frola-ip.co\u002Fblog\u002F503-service-unavailable\u002F), review possible causes before scheduling another attempt. For connection and read timeout settings, see the [Python Requests timeout guide](https:\u002F\u002Frola-ip.co\u002Fblog\u002Fpython-requests-timeout\u002F).\\n\\n## How to Adapt the Scraper to a Real Yellow Pages Website\\n\\nOnce the local run works, use the same downloader and CSV pipeline with your permitted directory source. The work is in mapping the real URLs and HTML to the parser's fields. No live YellowPages.com collection or proxy run is included in the recorded results.\\n\\n### 1 | Inspect a Search Page and Its Pagination\\n\\nOpen a permitted category-and-location search in your browser. Record the exact URL and filters so that each page belongs to the same query. Follow the next-page link once and compare its destination with the first URL: pagination may use a query parameter, a path segment, or a client-side request. Copy the actual destinations instead of guessing a page-number format.\\n\\nCreate `approved_urls.txt` in the project folder with one permitted page URL per line. Begin with one URL, then add a second page after confirming its contents. The downloader accepts one origin per batch, where the origin is the scheme, hostname, and optional port. A redirect to a different hostname requires review and an updated URL list; redirects are not followed automatically.\\n\\n### 2 | Fetch One Page and Check What Was Returned\\n\\nReplace `https:\u002F\u002Fapproved.example` below with the origin of your permitted source. Run these commands from the project folder with its Python environment:\\n\\n```powershell\\n$env:CONFIRMED_DATA_PERMISSION = 'yes'\\npython fetch_pages.py --urls approved_urls.txt --origin https:\u002F\u002Fapproved.example --out-dir real-pilot --delay 2\\n```\\n\\nUse `.\\\\.venv\\\\Scripts\\\\python.exe` instead of `python` in PowerShell if the environment is not activated. The two-second delay is an example; set it to the source's permitted interval. The confirmation variable records your decision and does not establish permission.\\n\\nInspect `real-pilot\u002Fhttp_manifest.csv` first. A usable pilot response must be recorded as `saved`, with HTTP 200 and HTML content. Open the saved file in a text editor and search for a business name visible in the browser. If the name is missing, inspect the response for a login screen, verification page, or JavaScript shell. Browser-rendered listings are not necessarily present in the HTML returned to Requests; use a permitted API or a separately designed browser workflow if required.\\n\\n### 3 | Map Actual Listing Fields to the Parser\\n\\nIn browser developer tools, inspect a listing's name and move upward to the element containing that listing's fields. Find a selector that matches every listing card once, then test it against the saved HTML. Select fields relative to each card so that a name from one business cannot be paired with a phone from another.\\n\\nUpdate `extract_page()` in `yellowpages_pipeline.py` using the following mapping. These are the current sample values to replace, not verified YellowPages.com selectors:\\n\\n| Parser input | Sample selector or attribute | What to check on the real page |\\n| --- | --- | --- |\\n| Listing container | `article.result` | One element per listing, including the intended sponsored\u002Forganic scope |\\n| Business name and detail link | `a.business-name` | Visible name and actual `href` |\\n| Category | `.categories` | Whether there is one category or several; define how multiple values are stored |\\n| City and state | `.locality` | The sample splits at the last comma; change this for a different location format |\\n| Phone text | `.phones` | Preserve original text; the supplied normalization is for North American ten-digit numbers |\\n| Street address | `.street-address` | Keep separate from city\u002Fstate for fallback duplicate matching |\\n| Stable listing identifier | `data-business-id` | Use a source-provided stable ID if present; do not invent one from page position |\\n| Sponsored status | `data-sponsored` | Adapt only when an explicit source label exists; do not infer organic status from a missing sample attribute |\\n\\nIf a detail link is relative, resolve it against the page's retrieval URL with Python's `urllib.parse.urljoin`. Use the manifest to associate `saved_file` with its URL. The supplied parser preserves links as written, so this requires adapting the parser before exporting a real source with relative links. If a field is unavailable, leave it empty or add an explicit unknown value rather than inventing data.\\n\\n### 4 | Validate the Pilot, Then Add Pages\\n\\nAfter adapting the parser, export the pilot:\\n\\n```bash\\npython yellowpages_pipeline.py --input-dir real-pilot --out-dir real-pilot-results\\n```\\n\\nCompare a few records against the saved page: name, category, city\u002Fstate, raw phone, address, and detail link should belong to the same listing. Compare the number of extracted cards with the intended listings on each page. A nonempty batch can still contain a page with zero matches; the current parser raises an error only when the combined input produces no cards.\\n\\nOnce the pilot passes, add the remaining permitted pagination URLs and retrieve them into a fresh directory. Watch for repeated pages, duplicate listings across pages, and unexpected changes in card counts. Keep category and city totals tied to the collected query, not to the entire market. If a request returns 403 or 429, the downloader records it and stops; review access or rate-limit requirements before starting a new batch. It does not automatically wait for or apply `Retry-After`.\\n\\n## Where Rola IP Fits in an Authorized Directory Workflow\\n\\nFor a project that needs a managed network exit, proxy configuration belongs in the HTTP request layer. HTML parsing and CSV analysis remain the responsibility of BeautifulSoup and the local pipeline. Select an exit and session configuration that fits the permitted source and the connection details available to your account.\\n\\nIn this script, `--use-env-proxy` enables Requests to read proxy environment settings; otherwise `session.trust_env` is `False`. The local commands above omit this flag and connect directly. For connection and authentication examples, see the [Python Requests proxy guide](https:\u002F\u002Frola-ip.co\u002Fblog\u002Fpython-requests-proxy\u002F).\\n\\nFor an external source you are allowed to use, create `approved_urls.txt` with the permitted URLs and replace the placeholders below. The example uses an HTTPS destination and an HTTP proxy URL. Keep credentials out of source files and shared logs; percent-encode reserved characters in username and password components when constructing a proxy URL.\\n\\n```bash\\n# macOS \u002F Linux: replace placeholders with your connection details\\nexport HTTPS_PROXY=\\\"http:\u002F\u002FUSERNAME:PASSWORD@HOST:PORT\\\"\\nexport CONFIRMED_DATA_PERMISSION=yes\\npython fetch_pages.py --urls approved_urls.txt --origin https:\u002F\u002Fapproved.example --out-dir external-run --use-env-proxy --delay 2\\n```\\n\\nFor PowerShell, set the corresponding environment variables with `$env:HTTPS_PROXY = 'http:\u002F\u002FUSERNAME:PASSWORD@HOST:PORT'` and `$env:CONFIRMED_DATA_PERMISSION = 'yes'`, then run the same command with the project's Python executable. Choose the interval based on the source's requirements. The confirmation flag records your decision to proceed; it does not determine permission.\\n\\nThis is the configuration path for a separate external run. The reported results above were measured locally without a proxy. A proxy changes the connection path; it does not grant data-use permission or guarantee access through CAPTCHAs or rate limits.\\n\\n\\n## Conclusion\\n\\nA useful directory workflow retains provenance, distinguishes retrieval errors from parsing errors, and checks the exported records. The supplied project demonstrates those steps on a reproducible fictional dataset, with explicit stop behavior for 403\u002F429 and city\u002Fstate-aware summaries. Start with the sample, then adapt field mappings and request settings to a source you are permitted to use.\\n\\n## Appendix A | Complete Python Programs\\n\\nSave each complete program below in your `project` folder as UTF-8 text. Install the two pinned packages in Step 1, then save the input lists from Appendix B and the HTML pages from Appendix C before running the commands. The Python code blocks can be copied directly; retain their indentation.\\n\\n### A1 | Local Sample Server\\n\\nSave as `serve_pages.py`.\\n\\n```python\\n\\\"\\\"\\\"Start a local HTTP server for reproducible, permission-controlled pages.\\\"\\\"\\\"\\nfrom __future__ import annotations\\nimport argparse\\nfrom http.server import BaseHTTPRequestHandler, ThreadingHTTPServer\\nfrom pathlib import Path\\n\\nBASE = Path(__file__).resolve().parent \u002F 'html'\\n\\nclass DirectoryHandler(BaseHTTPRequestHandler):\\n    def do_GET(self):\\n        route = self.path.split('?', 1)[0]\\n        if route.startswith('\u002Fcatalog\u002Fpage-') and route.endswith('.html'):\\n            number = route.removeprefix('\u002Fcatalog\u002Fpage-').removesuffix('.html')\\n            if number in {'1', '2', '3'}:\\n                path = BASE \u002F f'approved_directory_page_{number}.html'\\n                content = path.read_bytes()\\n                self.send_response(200)\\n                self.send_header('Content-Type', 'text\u002Fhtml; charset=utf-8')\\n                self.send_header('Content-Length', str(len(content)))\\n                self.end_headers()\\n                self.wfile.write(content)\\n                return\\n        if route in {'\u002Fstatus\u002F403', '\u002Fstatus\u002F429', '\u002Fstatus\u002F503'}:\\n            status = int(route.rsplit('\u002F', 1)[-1])\\n            self.send_response(status)\\n            self.send_header('Content-Type', 'text\u002Fplain; charset=utf-8')\\n            self.end_headers()\\n            self.wfile.write(f'HTTP {status}: request not available'.encode())\\n            return\\n        self.send_error(404, 'Route not found')\\n\\n    def log_message(self, fmt, *args):\\n        print('HTTP access: ' + fmt % args, flush=True)\\n\\n\\ndef main():\\n    ap = argparse.ArgumentParser()\\n    ap.add_argument('--port', type=int, default=8765)\\n    args = ap.parse_args()\\n    print(f'Local permitted directory: http:\u002F\u002F127.0.0.1:{args.port}\u002Fcatalog\u002Fpage-1.html', flush=True)\\n    ThreadingHTTPServer(('127.0.0.1', args.port), DirectoryHandler).serve_forever()\\n\\nif __name__ == '__main__':\\n    main()\\n```\\n\\n### A2 | Page Retrieval and Stop Handling\\n\\nSave as `fetch_pages.py`.\\n\\n```python\\n\\\"\\\"\\\"Retrieve one permitted origin; stop the batch on HTTP 403 or 429.\\\"\\\"\\\"\\nfrom __future__ import annotations\\nimport argparse\\nimport csv\\nimport hashlib\\nimport os\\nimport time\\nfrom datetime import datetime, timezone\\nfrom pathlib import Path\\nfrom urllib.parse import urlparse\\nimport requests\\n\\nCOLUMNS = ('requested_url', 'final_url', 'status', 'content_type',\\n           'saved_file', 'sha256', 'retrieved_utc', 'outcome')\\nMAX_BYTES = 2_000_000\\n\\ndef fetch(urls_file: Path, out_dir: Path, origin: str,\\n          proxy_env: bool = False, delay: float = 1.0):\\n    parsed_origin = urlparse(origin)\\n    if (parsed_origin.scheme not in ('http', 'https') or not parsed_origin.netloc\\n            or parsed_origin.username or parsed_origin.path not in ('', '\u002F')\\n            or parsed_origin.query or parsed_origin.fragment):\\n        raise ValueError('Origin must contain only scheme, host and optional port')\\n    if delay \u003C 0:\\n        raise ValueError('Delay must be nonnegative')\\n    expected = (parsed_origin.scheme, parsed_origin.netloc)\\n    urls = [s.strip() for s in urls_file.read_text(encoding='utf-8').splitlines()\\n            if s.strip() and not s.lstrip().startswith('#')]\\n    if not urls:\\n        raise ValueError('No URLs supplied')\\n    # Validate the whole batch before sending any requests.\\n    for url in urls:\\n        parsed = urlparse(url)\\n        if (parsed.scheme, parsed.netloc) != expected or parsed.username:\\n            raise ValueError('URL outside approved origin or contains credentials')\\n    if out_dir.exists() and any(out_dir.iterdir()):\\n        raise ValueError('Output directory must be new or empty; use a fresh run directory')\\n    out_dir.mkdir(parents=True, exist_ok=True)\\n    report = []\\n    with requests.Session() as session:\\n        session.trust_env = bool(proxy_env)\\n        for i, url in enumerate(urls, 1):\\n            if i > 1:\\n                time.sleep(delay)\\n            row = dict.fromkeys(COLUMNS, '')\\n            row.update(requested_url=url, retrieved_utc=datetime.now(timezone.utc).isoformat(timespec='seconds'))\\n            try:\\n                with session.get(url, timeout=(5, 15), allow_redirects=False, stream=True) as response:\\n                    row.update(final_url=response.url, status=str(response.status_code),\\n                               content_type=response.headers.get('Content-Type', ''))\\n                    if response.status_code in (403, 429):\\n                        row['outcome'] = f'stopped_http_{response.status_code}'\\n                    elif 300 \u003C= response.status_code \u003C 400:\\n                        row['outcome'] = 'redirect_not_followed'\\n                    elif response.status_code == 200 and 'text\u002Fhtml' in row['content_type'].lower():\\n                        content = bytearray()\\n                        for chunk in response.iter_content(65536):\\n                            if len(content) + len(chunk) > MAX_BYTES:\\n                                row['outcome'] = 'skipped_size_limit'\\n                                break\\n                            content.extend(chunk)\\n                        else:\\n                            filename = f'page_{i:02d}.html'\\n                            (out_dir \u002F filename).write_bytes(content)\\n                            row.update(saved_file=filename, sha256=hashlib.sha256(content).hexdigest(), outcome='saved')\\n                    else:\\n                        row['outcome'] = 'skipped_non_html_or_status'\\n            except requests.RequestException as exc:\\n                row['outcome'] = 'connection_error_' + type(exc).__name__\\n            report.append(row)\\n            print(f\\\"HTTP {row['status'] or '-':>3}  {row['outcome']:\u003C26} {url}\\\")\\n            if row['status'] in ('403', '429'):\\n                break\\n    with (out_dir \u002F 'http_manifest.csv').open('w', encoding='utf-8-sig', newline='') as f:\\n        writer = csv.DictWriter(f, fieldnames=COLUMNS)\\n        writer.writeheader()\\n        writer.writerows(report)\\n    print('Manifest:', out_dir \u002F 'http_manifest.csv')\\n    print('Saved pages:', sum(r['outcome'] == 'saved' for r in report))\\n    return report\\n\\ndef main():\\n    p = argparse.ArgumentParser(description=__doc__)\\n    p.add_argument('--urls', type=Path, default=Path('urls.txt'))\\n    p.add_argument('--out-dir', type=Path, default=Path('downloaded'))\\n    p.add_argument('--origin', default='http:\u002F\u002F127.0.0.1:8765')\\n    p.add_argument('--use-env-proxy', action='store_true')\\n    p.add_argument('--delay', type=float, default=1.0)\\n    args = p.parse_args()\\n    if args.origin not in ('http:\u002F\u002F127.0.0.1:8765', 'http:\u002F\u002Flocalhost:8765'):\\n        if os.environ.get('CONFIRMED_DATA_PERMISSION') != 'yes':\\n            p.error('Confirm permission before setting CONFIRMED_DATA_PERMISSION=yes')\\n    fetch(args.urls, args.out_dir, args.origin, args.use_env_proxy, args.delay)\\n\\nif __name__ == '__main__':\\n    main()\\n```\\n\\n### A3 | Parsing, Deduplication, and CSV Reports\\n\\nSave as `yellowpages_pipeline.py`.\\n\\n```python\\n\\\"\\\"\\\"Read local business-directory HTML and create structured CSV reports.\\n\\nThe workflow reads HTML files already available on disk. It does not\\ncontact a website. Only process content you are allowed to use.\\n\\\"\\\"\\\"\\n\\nfrom __future__ import annotations\\n\\nimport argparse\\nimport csv\\nimport re\\nfrom collections import Counter\\nfrom pathlib import Path\\n\\nfrom bs4 import BeautifulSoup\\n\\n\\nFIELDS = [\\n    \\\"business_id\\\", \\\"name\\\", \\\"category\\\", \\\"city\\\", \\\"state\\\",\\n    \\\"phone_raw\\\", \\\"phone\\\", \\\"address\\\", \\\"listing_url\\\", \\\"sponsored\\\", \\\"source_file\\\",\\n]\\n\\n\\ndef field(node, css: str) -> str:\\n    \\\"\\\"\\\"Return text from one matching element; otherwise an empty string.\\\"\\\"\\\"\\n    element = node.select_one(css)\\n    if element is None:\\n        return \\\"\\\"\\n    return element.get_text(\\\" \\\", strip=True)\\n\\n\\ndef normalize_phone(text: str) -> str:\\n    \\\"\\\"\\\"Format recognizable North American 10-digit phone numbers.\\\"\\\"\\\"\\n    digits = re.sub(r\\\"\\\\D\\\", \\\"\\\", text)\\n    if len(digits) == 11 and digits.startswith(\\\"1\\\"):\\n        digits = digits[1:]\\n    if len(digits) != 10:\\n        return \\\"\\\"\\n    return f\\\"{digits[:3]}-{digits[3:6]}-{digits[6:]}\\\"\\n\\n\\ndef extract_page(path: Path) -> list[dict[str, str]]:\\n    \\\"\\\"\\\"Extract business cards from one locally saved HTML file.\\\"\\\"\\\"\\n    html = path.read_text(encoding=\\\"utf-8\\\")\\n    soup = BeautifulSoup(html, \\\"html.parser\\\")\\n    records = []\\n\\n    for card in soup.select(\\\"article.result\\\"):\\n        name_link = card.select_one(\\\"a.business-name\\\")\\n        location = field(card, \\\".locality\\\")\\n        city, separator, state = location.rpartition(\\\",\\\")\\n\\n        record = {\\n            \\\"business_id\\\": card.get(\\\"data-business-id\\\", \\\"\\\").strip(),\\n            \\\"name\\\": field(card, \\\".business-name\\\"),\\n            \\\"category\\\": field(card, \\\".categories\\\"),\\n            \\\"city\\\": city.strip() if separator else location.strip(),\\n            \\\"state\\\": state.strip() if separator else \\\"\\\",\\n            \\\"phone_raw\\\": field(card, \\\".phones\\\"),\\n            \\\"phone\\\": normalize_phone(field(card, \\\".phones\\\")),\\n            \\\"address\\\": field(card, \\\".street-address\\\"),\\n            \\\"listing_url\\\": (\\n                name_link.get(\\\"href\\\", \\\"\\\").strip()\\n                if name_link else \\\"\\\"\\n            ),\\n            \\\"sponsored\\\": (\\n                \\\"Yes\\\" if card.get(\\\"data-sponsored\\\") == \\\"Y\\\"\\n                else \\\"No\\\"\\n            ),\\n            \\\"source_file\\\": path.name,\\n        }\\n        records.append(record)\\n\\n    return records\\n\\n\\ndef save_csv(path: Path, columns: list[str], records: list[dict]):\\n    \\\"\\\"\\\"Write Excel-compatible UTF-8 CSV with a header row.\\\"\\\"\\\"\\n    with path.open(\\\"w\\\", encoding=\\\"utf-8-sig\\\", newline=\\\"\\\") as f:\\n        writer = csv.DictWriter(f, fieldnames=columns)\\n        writer.writeheader()\\n        writer.writerows(records)\\n\\n\\ndef run(input_dir: Path, out_dir: Path) -> dict[str, int]:\\n    \\\"\\\"\\\"Parse, deduplicate, summarize, and export local HTML records.\\\"\\\"\\\"\\n    manifest = input_dir \u002F \\\"http_manifest.csv\\\"\\n    if manifest.exists():\\n        with manifest.open(encoding=\\\"utf-8-sig\\\", newline=\\\"\\\") as f:\\n            names = [row[\\\"saved_file\\\"] for row in csv.DictReader(f)\\n                     if row[\\\"outcome\\\"] == \\\"saved\\\"]\\n        if any(Path(name).name != name for name in names):\\n            raise ValueError(\\\"Invalid filename in manifest\\\")\\n        html_files = [input_dir \u002F name for name in names]\\n    else:\\n        html_files = sorted(input_dir.glob(\\\"*.html\\\"))\\n    if not html_files:\\n        raise ValueError(f\\\"No .html files in {input_dir}\\\")\\n\\n    candidates = []\\n    for path in html_files:\\n        candidates.extend(extract_page(path))\\n\\n    if not candidates:\\n        raise ValueError(\\\"No business cards found; inspect the HTML and selectors\\\")\\n\\n    kept = []\\n    excluded = []\\n    seen = set()\\n\\n    for record in candidates:\\n        # Incomplete fallback identities stay separate for manual review.\\n        identity = tuple(\\\" \\\".join(record[k].casefold().split())\\n                         for k in (\\\"name\\\", \\\"city\\\", \\\"state\\\", \\\"address\\\"))\\n        key = ((\\\"id\\\", record[\\\"business_id\\\"]) if record[\\\"business_id\\\"] else\\n               (\\\"address\\\", *identity) if all(identity) else (\\\"unresolved\\\", len(kept)))\\n        if not record[\\\"name\\\"] or not record[\\\"city\\\"]:\\n            excluded.append({**record, \\\"reason\\\": \\\"missing essential field\\\"})\\n        elif key in seen:\\n            excluded.append({**record, \\\"reason\\\": \\\"duplicate\\\"})\\n        else:\\n            seen.add(key)\\n            kept.append(record)\\n\\n    kept.sort(key=lambda r: (r[\\\"city\\\"], r[\\\"category\\\"], r[\\\"name\\\"]))\\n    category_counts = Counter(r[\\\"category\\\"] for r in kept)\\n    city_counts = Counter((r[\\\"city\\\"], r[\\\"state\\\"]) for r in kept)\\n    cross_counts = Counter(\\n        (r[\\\"city\\\"], r[\\\"state\\\"], r[\\\"category\\\"]) for r in kept\\n    )\\n\\n    out_dir.mkdir(parents=True, exist_ok=True)\\n    save_csv(out_dir \u002F \\\"businesses.csv\\\", FIELDS, kept)\\n\\n    category_rows = [\\n        {\\\"category\\\": name, \\\"count\\\": count}\\n        for name, count in sorted(category_counts.items())\\n    ]\\n    save_csv(\\n        out_dir \u002F \\\"categories.csv\\\", [\\\"category\\\", \\\"count\\\"],\\n        category_rows,\\n    )\\n\\n    city_rows = [\\n        {\\\"city\\\": city, \\\"state\\\": state, \\\"count\\\": count}\\n        for (city, state), count in sorted(city_counts.items())\\n    ]\\n    save_csv(out_dir \u002F \\\"cities.csv\\\", [\\\"city\\\", \\\"state\\\", \\\"count\\\"], city_rows)\\n\\n    cross_rows = [\\n        {\\\"city\\\": city, \\\"state\\\": state, \\\"category\\\": category, \\\"count\\\": count}\\n        for (city, state, category), count in sorted(cross_counts.items())\\n    ]\\n    save_csv(\\n        out_dir \u002F \\\"city_category.csv\\\",\\n        [\\\"city\\\", \\\"state\\\", \\\"category\\\", \\\"count\\\"], cross_rows,\\n    )\\n    save_csv(out_dir \u002F \\\"excluded.csv\\\", FIELDS + [\\\"reason\\\"], excluded)\\n\\n    summary = {\\n        \\\"files\\\": len(html_files),\\n        \\\"cards\\\": len(candidates),\\n        \\\"saved\\\": len(kept),\\n        \\\"duplicates\\\": sum(\\n            r[\\\"reason\\\"] == \\\"duplicate\\\" for r in excluded\\n        ),\\n        \\\"missing_phone\\\": sum(not r[\\\"phone\\\"] for r in kept),\\n    }\\n\\n    print(f\\\"HTML files: {summary['files']} | Cards: {summary['cards']}\\\")\\n    print(f\\\"Unique businesses saved: {summary['saved']}\\\")\\n    print(f\\\"Duplicates removed: {summary['duplicates']}\\\")\\n    print(f\\\"Missing phone: {summary['missing_phone']}\\\")\\n    print(f\\\"Outputs: {out_dir.resolve()}\\\")\\n    for category, count in sorted(category_counts.items()):\\n        print(f\\\"  {category:\u003C16} {count}\\\")\\n\\n    return summary\\n\\n\\ndef main() -> None:\\n    parser = argparse.ArgumentParser(\\n        description=\\\"Authorized business directory HTML -> CSV\\\"\\n    )\\n    parser.add_argument(\\n        \\\"--input-dir\\\", type=Path, default=Path(\\\"html\\\")\\n    )\\n    parser.add_argument(\\n        \\\"--out-dir\\\", type=Path, default=Path(\\\"results\\\")\\n    )\\n    args = parser.parse_args()\\n    run(args.input_dir, args.out_dir)\\n\\n\\nif __name__ == \\\"__main__\\\":\\n    main()\\n```\\n\\n## Appendix B | Input Lists and Execution Order\\n\\n`urls.txt` contains:\\n\\n```text\\nhttp:\u002F\u002F127.0.0.1:8765\u002Fcatalog\u002Fpage-1.html\\nhttp:\u002F\u002F127.0.0.1:8765\u002Fcatalog\u002Fpage-2.html\\nhttp:\u002F\u002F127.0.0.1:8765\u002Fcatalog\u002Fpage-3.html\\n```\\n\\n`rejected_urls.txt` contains:\\n\\n```text\\nhttp:\u002F\u002F127.0.0.1:8765\u002Fstatus\u002F429\\nhttp:\u002F\u002F127.0.0.1:8765\u002Fcatalog\u002Fpage-1.html\\n```\\n\\n```bash\\n# Terminal 1, from the project folder\\npython serve_pages.py --port 8765\\n\\n# Terminal 2, using the project environment\\npython -m pip install requests==2.33.1 beautifulsoup4==4.14.3\\npython fetch_pages.py --urls urls.txt --origin http:\u002F\u002F127.0.0.1:8765 --out-dir downloaded\\npython yellowpages_pipeline.py --input-dir downloaded --out-dir results\\npython fetch_pages.py --urls rejected_urls.txt --origin http:\u002F\u002F127.0.0.1:8765 --out-dir rejected-run\\n```\\n\\nUse new output directory names for later retrieval runs. In PowerShell, replace `python` with `.\\\\.venv\\\\Scripts\\\\python.exe` after creating the virtual environment in Step 1. On macOS or Linux, activate that environment first. Check the resulting counts against Steps 4 and 5.\\n\\n## Appendix C | Complete Sample HTML Inputs\\n\\nSave the following three blocks as UTF-8 files in `project\u002Fhtml`. Each page contains four fictional cards; two businesses appear on more than one page. The three pages therefore yield twelve cards and ten retained businesses. These fixtures exercise the sample selectors in Appendix A.\\n\\n### C1 | Page 1\\n\\nSave as `html\u002Fapproved_directory_page_1.html`.\\n\\n```html\\n\u003C!doctype html>\\n\u003Chtml lang=\\\"en\\\">\\n\u003Cmeta charset=\\\"utf-8\\\">\\n\u003Ctitle>Synthetic directory sample\u003C\u002Ftitle>\\n\u003Ch1>Fictional teaching data\u003C\u002Fh1>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B01\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB01\\\">Sample Orchard Plumbing\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Plumbers\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Francisco, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">415-555-0101\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">10 Demo Street\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B02\\\" data-sponsored=\\\"Y\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB02\\\">Sample Harbor Dental\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Dentists\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Francisco, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">415-555-0102\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">20 Demo Street\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B03\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB03\\\">Sample Northstar Electric\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Electricians\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">Oakland, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">510-555-0103\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">30 Demo Avenue\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B04\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB04\\\">Sample Bay Auto\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Auto Repair\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Jose, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">408-555-0104\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">40 Demo Road\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003C\u002Fhtml>\\n```\\n\\n### C2 | Page 2\\n\\nSave as `html\u002Fapproved_directory_page_2.html`.\\n\\n```html\\n\u003C!doctype html>\\n\u003Chtml lang=\\\"en\\\">\\n\u003Cmeta charset=\\\"utf-8\\\">\\n\u003Ctitle>Synthetic directory sample\u003C\u002Ftitle>\\n\u003Ch1>Fictional teaching data\u003C\u002Fh1>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B05\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB05\\\">Sample City Plumbing\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Plumbers\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">Oakland, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">510-555-0105\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">50 Demo Avenue\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B06\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB06\\\">Sample Mission Dental\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Dentists\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Jose, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">\\n\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">60 Demo Road\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B07\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB07\\\">Sample Maple Auto\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Auto Repair\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Francisco, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">415-555-0107\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">70 Demo Street\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B08\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB08\\\">Sample Westline Electric\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Electricians\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">Oakland, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">510-555-0108\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">80 Demo Avenue\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003C\u002Fhtml>\\n```\\n\\n### C3 | Page 3\\n\\nSave as `html\u002Fapproved_directory_page_3.html`.\\n\\n```html\\n\u003C!doctype html>\\n\u003Chtml lang=\\\"en\\\">\\n\u003Cmeta charset=\\\"utf-8\\\">\\n\u003Ctitle>Synthetic directory sample\u003C\u002Ftitle>\\n\u003Ch1>Fictional teaching data\u003C\u002Fh1>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B09\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB09\\\">Sample Valley Plumbing\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Plumbers\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Jose, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">408-555-0109\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">90 Demo Road\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B10\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB10\\\">Sample Summit Dental\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Dentists\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Francisco, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">415-555-0110\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">100 Demo Street\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B01\\\" data-sponsored=\\\"N\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB01\\\">Sample Orchard Plumbing\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Plumbers\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Francisco, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">415-555-0101\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">10 Demo Street\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003Carticle class=\\\"result\\\" data-business-id=\\\"B02\\\" data-sponsored=\\\"Y\\\">\\n\u003Ca class=\\\"business-name\\\" href=\\\"https:\u002F\u002Fexample.com\u002Fbusiness\u002FB02\\\">Sample Harbor Dental\u003C\u002Fa>\\n\u003Cspan class=\\\"categories\\\">Dentists\u003C\u002Fspan>\\n\u003Cspan class=\\\"locality\\\">San Francisco, CA\u003C\u002Fspan>\\n\u003Cspan class=\\\"phones\\\">415-555-0102\u003C\u002Fspan>\\n\u003Cspan class=\\\"street-address\\\">20 Demo Street\u003C\u002Fspan>\\n\u003C\u002Farticle>\\n\u003C\u002Fhtml>\\n```\\n\\n\\n## FAQ\\n\\n### Does This Example Scrape Live YellowPages.com Pages?\\n\\nNo. It requests fictional pages from a local HTTP server. The field selectors, record counts, and test results apply to that sample. To use a different directory, confirm permitted access and reuse, inspect its page structure, and adapt the selectors and pagination inputs.\\n\\n### Why Can HTTP 200 Produce No Business Records?\\n\\nHTTP 200 indicates a successful HTTP response, not that the expected business cards are present. Inspect the returned HTML for a login page, verification page, JavaScript-only content, or changed selectors. The sample parser raises an error if it finds no matching cards across the selected inputs.\\n\\n### Can City Counts Be Used as Market Share?\\n\\nNo. Directory counts depend on coverage, search conditions, advertising, and collection time. Keep city and state together when grouping locations, use consistent selection criteria, and describe the results as counts within the collected sample.\\n\\n### Why Keep Both CSV Reports and a Source Manifest?\\n\\nCSV reports make records usable for analysis. The manifest preserves retrieval URLs, timestamps, statuses, and content hashes. Match each record's `source_file` with the manifest's `saved_file` to trace where that record came from.\"},{\"children\":[],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"paragraph\",\"version\":1}],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}",{"items":34,"inline":47},[35,38,41,44],{"title":36,"desc":37},"Does This Example Scrape Live YellowPages.com Pages?","\u003Cp>No. It requests fictional pages from a local HTTP server. The field selectors, record counts, and test results apply to that sample. To use a different directory, confirm permitted access and reuse, inspect its page structure, and adapt the selectors and pagination inputs.\u003C\u002Fp>",{"title":39,"desc":40},"Why Can HTTP 200 Produce No Business Records?","\u003Cp>HTTP 200 indicates a successful HTTP response, not that the expected business cards are present. Inspect the returned HTML for a login page, verification page, JavaScript-only content, or changed selectors. The sample parser raises an error if it finds no matching cards across the selected inputs.\u003C\u002Fp>",{"title":42,"desc":43},"Can City Counts Be Used as Market Share?","\u003Cp>No. Directory counts depend on coverage, search conditions, advertising, and collection time. Keep city and state together when grouping locations, use consistent selection criteria, and describe the results as counts within the collected sample.\u003C\u002Fp>",{"title":45,"desc":46},"Why Keep Both CSV Reports and a Source Manifest?","\u003Cp>CSV reports make records usable for analysis. The manifest preserves retrieval URLs, timestamps, statuses, and content hashes. Match each record’s \u003Ccode>source_file\u003C\u002Fcode> with the manifest’s \u003Ccode>saved_file\u003C\u002Fcode> to trace where that record came from.\u003C\u002Fp>",true,{"@context":49,"@type":50,"@id":51,"mainEntity":52},"https:\u002F\u002Fschema.org","FAQPage","https:\u002F\u002Frola-ip.co\u002Fblog\u002Fweb-scraping-yellow-pages\u002F#faq",[53,58,61,64],{"@type":54,"name":36,"acceptedAnswer":55},"Question",{"@type":56,"text":57},"Answer","No. It requests fictional pages from a local HTTP server. The field selectors, record counts, and test results apply to that sample. To use a different directory, confirm permitted access and reuse, inspect its page structure, and adapt the selectors and pagination inputs.",{"@type":54,"name":39,"acceptedAnswer":59},{"@type":56,"text":60},"HTTP 200 indicates a successful HTTP response, not that the expected business cards are present. Inspect the returned HTML for a login page, verification page, JavaScript-only content, or changed selectors. The sample parser raises an error if it finds no matching cards across the selected inputs.",{"@type":54,"name":42,"acceptedAnswer":62},{"@type":56,"text":63},"No. Directory counts depend on coverage, search conditions, advertising, and collection time. Keep city and state together when grouping locations, use consistent selection criteria, and describe the results as counts within the collected sample.",{"@type":54,"name":45,"acceptedAnswer":65},{"@type":56,"text":66},"CSV reports make records usable for analysis. The manifest preserves retrieval URLs, timestamps, statuses, and content hashes. Match each record’s source_file with the manifest’s saved_file to trace where that record came from.","{\"@context\":\"https:\u002F\u002Fschema.org\",\"@type\":\"FAQPage\",\"@id\":\"https:\u002F\u002Frola-ip.co\u002Fblog\u002Fweb-scraping-yellow-pages\u002F#faq\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"Does This Example Scrape Live YellowPages.com Pages?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. It requests fictional pages from a local HTTP server. The field selectors, record counts, and test results apply to that sample. To use a different directory, confirm permitted access and reuse, inspect its page structure, and adapt the selectors and pagination inputs.\"}},{\"@type\":\"Question\",\"name\":\"Why Can HTTP 200 Produce No Business Records?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"HTTP 200 indicates a successful HTTP response, not that the expected business cards are present. Inspect the returned HTML for a login page, verification page, JavaScript-only content, or changed selectors. The sample parser raises an error if it finds no matching cards across the selected inputs.\"}},{\"@type\":\"Question\",\"name\":\"Can City Counts Be Used as Market Share?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. Directory counts depend on coverage, search conditions, advertising, and collection time. Keep city and state together when grouping locations, use consistent selection criteria, and describe the results as counts within the collected sample.\"}},{\"@type\":\"Question\",\"name\":\"Why Keep Both CSV Reports and a Source Manifest?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"CSV reports make records usable for analysis. The manifest preserves retrieval URLs, timestamps, statuses, and content hashes. Match each record’s source_file with the manifest’s saved_file to trace where that record came from.\"}}]}",[69],"\u002Fblog\u002Fweb-scraping-yellow-pages\u002F",{"prev":71,"next":82,"related":93,"popular":127,"latest":193},{"id":72,"title":73,"slug":74,"feature_image":75,"published_at":76,"twitter_title":77,"primary_tag":78,"tags":79},"6ad59b474956c90001bf19b9","How to Do Naver SEO: A Step-by-Step Tutorial","naver-seo","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F10\u002FHow-to-Do-Naver-SEO_-A-Step-by-Step-Tutorial.webp","2026-10-19T04:30:51.000Z","naver seo",{"name":20,"slug":20},[80,81],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":83,"title":84,"slug":85,"feature_image":86,"published_at":87,"twitter_title":88,"primary_tag":89,"tags":90},"6ad1e7f94956c90001bf18ff","Facebook Page Scraper: How to Scrape Facebook Pages in 2026","facebook-page-scraper","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F10\u002FFacebook-Page-Scraper-Guide-to-Page-Details-and-Proxies.webp","2026-10-16T09:08:47.000Z","how to scrape facebook pages",{"name":20,"slug":20},[91,92],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},[94,105,116],{"id":95,"title":96,"slug":97,"feature_image":98,"published_at":99,"twitter_title":100,"primary_tag":101,"tags":102},"6b0d3e4b92ab700001dc0a73","Scrape Indeed Jobs with Python: Extract Job Fields and Export to CSV","scrape-indeed-jobs","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FScrape-Indeed-Jobs.webp","2026-11-30T09:37:05.000Z","indeed job scraper",{"name":20,"slug":20},[103,104],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":106,"title":107,"slug":108,"feature_image":109,"published_at":110,"twitter_title":111,"primary_tag":112,"tags":113},"6b0d2bcb92ab700001dc0a12","Node.js HTTP Proxy Tutorial: Send HTTPS Requests with Rola IP and Verify the Exit IP","node-js-http-proxy","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FNode.js-HTTP-Proxy-Tutorial_-Send-HTTPS-Requests-with-Rola-IP-and-Verify-the-Exit-IP.webp","2026-11-30T07:58:57.000Z","node js http proxy",{"name":20,"slug":20},[114,115],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":117,"title":118,"slug":119,"feature_image":120,"published_at":121,"twitter_title":122,"primary_tag":123,"tags":124},"6b09485d92ab700001dc0953","How to Set Up Chrome DevTools MCP for Multi-Region Geo-Testing with Residential Proxies","chrome-devtools-mcp-proxy-setup","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002Fchrome-devtools-mcp-proxy-setup.webp","2026-11-27T09:22:44.000Z","chrome-devtools-mcp proxy setup",{"name":20,"slug":20},[125,126],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},[128,143,155,167,179],{"id":129,"title":130,"slug":131,"feature_image":132,"published_at":133,"twitter_title":134,"primary_tag":135,"tags":136},"6aa1292f4956c90001bef44e","ProxySite.com Review (2026): Is It Safe? 5 Best Alternatives","proxysite-review-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002FProxySite-Review-and--Alternatives-article-cover-image.webp","2026-09-09T10:16:50.000Z","proxysite",{"name":20,"slug":20},[137,138,141],{"name":20,"slug":20,"visibility":21},{"name":139,"slug":140,"visibility":21},"对比选型","comparisons",{"name":142,"slug":142,"visibility":21},"hot",{"id":144,"title":145,"slug":146,"feature_image":147,"published_at":148,"twitter_title":149,"primary_tag":150,"tags":151},"6a978f9a4956c90001bee8bb","BlockAway Alternatives: 6 Best Options (2026)","blockaway-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002FBlockAway-Alternatives-article-cover-image.webp","2026-09-02T03:14:08.000Z","blockaway alternative",{"name":20,"slug":20},[152,153,154],{"name":20,"slug":20,"visibility":21},{"name":139,"slug":140,"visibility":21},{"name":142,"slug":142,"visibility":21},{"id":156,"title":157,"slug":158,"feature_image":159,"published_at":160,"twitter_title":161,"primary_tag":162,"tags":163},"6a912ce84956c90001bee35d","HTTPX vs Requests vs aiohttp: Features, Performance, and Python Use Cases","httpx-vs-requests-vs-aiohttp","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FHTTPX-vs-Requests-vs-aiohttp-article-cover-image.webp","2026-08-28T07:27:34.000Z","httpx vs requests",{"name":20,"slug":20},[164,165,166],{"name":20,"slug":20,"visibility":21},{"name":139,"slug":140,"visibility":21},{"name":142,"slug":142,"visibility":21},{"id":168,"title":169,"slug":170,"feature_image":171,"published_at":172,"twitter_title":173,"primary_tag":174,"tags":175},"6a90fcea4956c90001bee256","8 Best Germany Proxies in 2026: Provider Comparison","best-germany-proxies","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FBest-Germany-Proxies-article-cover-image.webp","2026-08-28T03:40:55.000Z","germany proxy",{"name":20,"slug":20},[176,177,178],{"name":20,"slug":20,"visibility":21},{"name":139,"slug":140,"visibility":21},{"name":142,"slug":142,"visibility":21},{"id":180,"title":181,"slug":182,"feature_image":183,"published_at":184,"twitter_title":185,"primary_tag":186,"tags":187},"6a8e92664956c90001beddc2","Bing Rank Tracker: Reliable Local SERP Monitoring Guide","bing-rank-tracker","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F-------16.webp","2026-08-26T07:42:04.000Z","bing rank checker",{"name":20,"slug":20},[188,189,192],{"name":20,"slug":20,"visibility":21},{"name":190,"slug":191,"visibility":21},"应用场景","use-cases",{"name":142,"slug":142,"visibility":21},[194,207,218,229,240],{"id":195,"title":196,"slug":197,"feature_image":198,"published_at":199,"twitter_title":200,"primary_tag":201,"tags":202},"6b0946f492ab700001dc0920","Best Rotating Proxies in 2026 7 Rotating Proxy Providers Compared","best-rotating-proxies","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FBest-Rotating-Proxies-in-2026-7-Rotating-Proxy-Providers-Compared.webp","2026-11-27T09:07:09.000Z","best rotating proxies",{"name":20,"slug":20},[203,204],{"name":20,"slug":20,"visibility":21},{"name":205,"slug":206,"visibility":21},"排行榜","top-picks",{"id":208,"title":209,"slug":210,"feature_image":211,"published_at":212,"twitter_title":213,"primary_tag":214,"tags":215},"6b07a50492ab700001dc0603","How to Configure an NGINX Docker Reverse Proxy with Rola IP Egress","nginx-docker-reverse-proxy","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FHow-to-Configure-an-NGINX-Docker-Reverse-Proxy-with-Rola-IP-Egress-1.webp","2026-11-26T03:21:51.000Z","nginx docker reverse proxy",{"name":20,"slug":20},[216,217],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":219,"title":220,"slug":221,"feature_image":222,"published_at":223,"twitter_title":224,"primary_tag":225,"tags":226},"6b079b8692ab700001dc05ce","Android Proxy Settings for Mobile Network: The No-Root Guide (2026)","android-proxy-settings-mobile-network","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FAndroid-Proxy-Settings-for-Mobile-Network_-The-No-Root-Guide--2026-.webp","2026-11-26T03:10:40.000Z","android proxy settings mobile network",{"name":20,"slug":20},[227,228],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":230,"title":231,"slug":232,"feature_image":233,"published_at":234,"twitter_title":235,"primary_tag":236,"tags":237},"6b0655a092ab700001dc0440","Rammerhead Proxy: Setup, HTTP Upstreams and Alternatives","rammerhead-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002Frammerhead-alternatives.webp","2026-11-25T03:59:48.000Z","Rammerhead Proxy",{"name":20,"slug":20},[238,239],{"name":20,"slug":20,"visibility":21},{"name":139,"slug":140,"visibility":21},{"id":241,"title":242,"slug":243,"feature_image":244,"published_at":245,"twitter_title":246,"primary_tag":247,"tags":248},"6b05417f92ab700001dc034d","ProxyEmpire Review (2026): Our Best Alternative for Predictable Bulk Residential Use","proxyempire-review","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FProxyEmpire-Review--2026-_-Our-Best-Alternative-for-Predictable-Bulk-Residential-Use.webp","2026-11-24T08:12:53.000Z","proxyempire review",{"name":20,"slug":20},[249,250],{"name":20,"slug":20,"visibility":21},{"name":139,"slug":140,"visibility":21}]