Dataspryva

Use YellowPagesPK Business Directory & Lead Finder with Python

Browse Pakistan's YellowPagesPK.com directory by business category, run a keyword search, or fetch full profiles by listing URL. Get business names, addresses, cities, phone numbers, emails, websites, ratings, and claimed status.

1. Choose the data you need

Review the published README for supported collection modes, examples, and limits. The recipe below uses the current published input definition.

2. Prepare a source-based input

This JSON contains published prefills and required-field defaults. Review every value for your task before running it; it is not a promise of successful collection.

{
  "categories": [
    "restaurant"
  ],
  "cities": [],
  "fetchDetails": false,
  "listingUrls": [],
  "maxItems": 2,
  "minRating": 0,
  "mode": "byCategory",
  "onlyClaimed": false,
  "onlyWithEmail": false,
  "onlyWithPhone": false,
  "onlyWithWebsite": false,
  "searchQuery": "Lahore"
}

Download input.example.json and save your reviewed copy as input.json.

FieldTypeRequiredDescription
modestringrequiredHow to find businesses: browse a category archive, browse a city archive, run the site's keyword search, or open specific listing URLs.
categoriesarrayoptionalOne or more categories to browse (mode=byCategory), or exact category filters (other modes). In byCategory, Restaurant is used when the field is omitted; select additional categories to broaden the run, or leave the selection empty to crawl the entire directory (2,198 listings).
citiesarrayoptionalOne or more location terms to browse (mode=byCity). In other modes the same selection acts as an exact location filter. Leave empty to skip city browsing/filtering. All 65 published location terms are listed, including provinces and countries.
searchQuerystringoptionalWhat to search for (mode=search), e.g. a service, business name or city. The site's own relevance-ranked search is used, so 'restaurant lahore' narrows results well.
listingUrlsarrayoptionalYellowPagesPK.com business listing URLs to open directly (mode=byUrls). Non-YellowPagesPK hosts are rejected.
minRatingintegeroptionalOnly keep businesses rated at least this many stars (0-5). 0 disables the filter. Businesses without a published rating are excluded when this is above 0. Profile enrichment turns on automatically when the selected mode's fast path has no ratings.
onlyClaimedbooleanoptionalOnly keep listings claimed and verified by their owner on YellowPagesPK.com. Profile enrichment turns on automatically when the selected path has no claim badges.
onlyWithEmailbooleanoptionalOnly keep businesses with a published email. Turns on profile enrichment automatically.
onlyWithWebsitebooleanoptionalOnly keep businesses with a published website. Turns on profile enrichment automatically.
onlyWithPhonebooleanoptionalOnly keep businesses with a published phone number. Turns on profile enrichment automatically.
fetchDetailsbooleanoptionalOpen each listing page for description, email, website, hours, social links, gallery and coordinates (one extra request per business). Turn off for the cheapest list: category/city archives keep card fields, while search and whole-directory REST runs return name, category, city, description and dates.
maxItemsintegeroptionalMaximum number of business records to return. The directory currently contains 2,198 listings.

3. Start an Actor run

Set APIFY_TOKEN in your environment. Python 3.10 or newer is sufficient; this recipe uses no third-party packages.

Execution may incur charges. Review current pricing on Apify. The request asks for a 120-second timeout and a charge limit; these settings are subject to Apify’s pricing and do not guarantee an all-inclusive spending cap.

import json
import os
import urllib.request

# Save the schema-derived example as input.json; review and edit it first.
with open("input.json", encoding="utf-8") as stream:
    actor_input = json.load(stream)

token = os.environ["APIFY_TOKEN"]
request = urllib.request.Request(
    "https://api.apify.com/v2/acts/96dku08TQMyBliUur/runs?timeout=120&maxTotalChargeUsd=0.50",
    data=json.dumps(actor_input).encode("utf-8"),
    headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
    method="POST",
)
# This starts a potentially billable run. Do not automatically retry this POST.
with urllib.request.urlopen(request, timeout=40) as response:
    run = json.load(response)["data"]
print("Run ID:", run["id"])
print("Status:", run["status"])
# Inspect and download results in Apify Console once the run succeeds.

4. Inspect the actual results

Open the run in Apify Console and wait for a successful completion. Use the published output schema to locate results and the dataset schema to understand declared views. Missing or optional record fields must not be treated as guaranteed values.

YellowPagesPK.com business listings with categories, location, address, phone, email, website, hours, social links, photos, coordinates and publish dates.

Questions before you run

Which inputs are required?

The published required fields are mode

What does this guide verify?

The fields, prefills, and schema links are rendered from the published build. This is a usage recipe, not a paid live extraction test. Source availability and collection results can vary.

What if the run request times out?

Check Apify Console before retrying. The first request may already have created a run. Do not automatically repeat a run-creation POST.

Generated from source build 9ZaBl7uvgtmywvUcU and its README and schemas. Source changes regenerate this guide; no third-party editorial claims are inferred.