- 按办公地点而非总部查找公司,使用针对
offices_country_codes的in - 匹配公司描述或专长中的短语,使用
or和mode: "all" - 按曾任雇主查找人物,使用
past_company_names和not - 运行多步搜索,先运行公司搜索,再运行人物搜索
BRIGHTDATA_API_KEY 环境变量读取 API key,设置方法见 Business Search 快速入门。你的记录和 matched 数量会与示例响应不同,因为结果在不同运行之间会变化。
如何按办公地点而非总部查找公司
要查找在德国设有办公室的软件公司,而不论其总部在哪里,请按offices_country_codes 而非 headquarters_country_code 筛选。该字段是国家代码数组,接受 in,因此一个条件即可匹配在任一列出国家设有办公室的公司。Instant 和 Smart 接受同一意图的自然语言表述。
- Ludicrous
- Instant
- Smart
以下 Ludicrous 请求把行业中的 示例响应返回的三条记录中的第一条:
software 与办公国家代码中的 DE 组合在一起。text 条件设置了 mode: "all":测试中,默认模式只触及了一小部分匹配的公司,而且每次运行触及的部分都不同:示例请求curl --request POST "https://api.brightdata.com/search/company" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "ludicrous",
"query": {
"and": [
{ "text": { "industry": { "value": "software", "mode": "all" } } },
{ "in": { "offices_country_codes": ["DE"] } }
]
},
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
}'
import os
import requests
response = requests.post(
"https://api.brightdata.com/search/company",
headers={
"Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
"Content-Type": "application/json",
},
json={
"mode": "ludicrous",
"query": {
"and": [
{ "text": { "industry": { "value": "software", "mode": "all" } } },
{ "in": { "offices_country_codes": ["DE"] } }
]
},
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
},
)
print(response.text)
const response = await fetch("https://api.brightdata.com/search/company", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"mode": "ludicrous",
"query": {
"and": [
{ "text": { "industry": { "value": "software", "mode": "all" } } },
{ "in": { "offices_country_codes": ["DE"] } }
]
},
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
}),
});
console.log(await response.text());
{
"req_id": "rb8545422f0a1478690c2b51666b48de2",
"source": "linkedin_company",
"meta": {
"coverage_percent": 100,
"matched": 23123,
"offset": 0,
"limit": 3
},
"documents": [
{
"bright_id": "497e671df1de83a45eec09ac98062e8149b2f4cc8ca4e9cfbf89dc86a45404dd",
"data": {
"name": "Google",
"industry": "Software Development",
"headquarters_location": "Mountain View, CA",
"offices_country_codes": [
"PL",
"CA",
"CL",
"SE",
"AU",
"US",
"SG",
"DE",
"ES",
"FR",
"MX",
"CH",
"IT",
"IN",
"NL",
"CO",
"BR",
"HK",
"AR",
"PH",
"IL",
"IE",
"GB"
],
"website": "https://goo.gle/3DLEokh"
}
}
]
}
以下 Instant 请求用一句话表达该意图:示例请求示例响应返回的三条记录中的第一条:
curl --request POST "https://api.brightdata.com/search/company" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "instant",
"query": "Software companies with an office in Germany",
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
}'
import os
import requests
response = requests.post(
"https://api.brightdata.com/search/company",
headers={
"Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
"Content-Type": "application/json",
},
json={
"mode": "instant",
"query": "Software companies with an office in Germany",
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
},
)
print(response.text)
const response = await fetch("https://api.brightdata.com/search/company", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"mode": "instant",
"query": "Software companies with an office in Germany",
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
}),
});
console.log(await response.text());
{
"req_id": "rd24753db731c4a6b806c638fad544cc5",
"source": "linkedin_company",
"meta": {
"coverage_percent": 100,
"matched": 749,
"offset": 0,
"limit": 3
},
"documents": [
{
"bright_id": "12d1ece1155dded506f3473ba5574f2e0e6c067f420dcaf0bda9e9cec58488dd",
"data": {
"name": "Maxon",
"industry": "Software Development",
"headquarters_location": "Bad Homburg",
"offices_country_codes": [
"DE",
"US",
"CA",
"JP"
],
"website": "https://www.maxon.net/"
}
}
]
}
以下 Smart 请求发送同一句话,并按每条记录对请求的契合程度对候选结果排序:示例请求示例响应返回的三条记录中的第一条:
curl --request POST "https://api.brightdata.com/search/company" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "smart",
"query": "Software companies with an office in Germany",
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
}'
import os
import requests
response = requests.post(
"https://api.brightdata.com/search/company",
headers={
"Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
"Content-Type": "application/json",
},
json={
"mode": "smart",
"query": "Software companies with an office in Germany",
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
},
)
print(response.text)
const response = await fetch("https://api.brightdata.com/search/company", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"mode": "smart",
"query": "Software companies with an office in Germany",
"limit": 3,
"view": { "fields": ["name", "industry", "headquarters_location", "offices_country_codes", "website"] }
}),
});
console.log(await response.text());
{
"req_id": "raf8ab94a0ef649cd8d0eb2a58c800310",
"source": "linkedin_company",
"meta": {
"coverage_percent": 100,
"matched": 746,
"offset": 0,
"limit": 3
},
"documents": [
{
"bright_id": "12d1ece1155dded506f3473ba5574f2e0e6c067f420dcaf0bda9e9cec58488dd",
"data": {
"name": "Maxon",
"industry": "Software Development",
"headquarters_location": "Bad Homburg",
"offices_country_codes": [
"DE",
"US",
"CA",
"JP"
],
"website": "https://www.maxon.net/"
}
}
]
}
如何匹配公司描述或专长中的短语
要查找在英国设有办公室的欺诈检测软件提供商,请匹配公司自我描述文本中的词语。fraud detection software 可能出现在 about 或 specialties 中,因此结构化查询用 or 同时检查两个字段,并用 mode: "all" 要求三个词出现在同一字段中。这是词语匹配,并不证明该公司销售欺诈检测产品:公司可能描述了欺诈检测相关工作,却并不以此作为产品。
- Ludicrous
- Smart
以下 Ludicrous 请求接受任一字段命中,并要求在 GB 设有办公室:示例请求示例响应返回的三条记录中的第一条:
curl --request POST "https://api.brightdata.com/search/company" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "ludicrous",
"query": {
"and": [
{
"or": [
{ "text": { "about": { "value": "fraud detection software", "mode": "all" } } },
{ "text": { "specialties": { "value": "fraud detection software", "mode": "all" } } }
]
},
{ "in": { "offices_country_codes": ["GB"] } }
]
},
"limit": 3,
"view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
}'
import os
import requests
response = requests.post(
"https://api.brightdata.com/search/company",
headers={
"Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
"Content-Type": "application/json",
},
json={
"mode": "ludicrous",
"query": {
"and": [
{
"or": [
{ "text": { "about": { "value": "fraud detection software", "mode": "all" } } },
{ "text": { "specialties": { "value": "fraud detection software", "mode": "all" } } }
]
},
{ "in": { "offices_country_codes": ["GB"] } }
]
},
"limit": 3,
"view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
},
)
print(response.text)
const response = await fetch("https://api.brightdata.com/search/company", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"mode": "ludicrous",
"query": {
"and": [
{
"or": [
{ "text": { "about": { "value": "fraud detection software", "mode": "all" } } },
{ "text": { "specialties": { "value": "fraud detection software", "mode": "all" } } }
]
},
{ "in": { "offices_country_codes": ["GB"] } }
]
},
"limit": 3,
"view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
}),
});
console.log(await response.text());
{
"req_id": "r9a82f304d62748ddabd98aa954291bcd",
"source": "linkedin_company",
"meta": {
"coverage_percent": 100,
"matched": 78,
"offset": 0,
"limit": 3
},
"documents": [
{
"bright_id": "b8b445ba5ddcf7dab8342ce3e26609e07f5d864b5dfcef813e7ce2d78bc5f1a5",
"data": {
"name": "FICO",
"industry": "Software Development",
"specialties": "Predictive Analytics, Decision Management Tools and Applications, Scores, Consultancy, B2B Enterprise Software, Enterprise Software, Decision Technology, Enterprise Fraud, Cyber security, Fraud Detection, Loan origination software, Applied Intelligence, and AI",
"offices_country_codes": [
"GB",
"IN",
"SG",
"US"
],
"website": "https://www.fico.com/"
}
}
]
}
以下 Smart 请求用一句话表达该意图,并按每条记录对请求的契合程度对候选结果排序:示例请求示例响应返回的三条记录中的第一条:
curl --request POST "https://api.brightdata.com/search/company" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "smart",
"query": "Fraud-detection software providers with an office in the United Kingdom",
"limit": 3,
"view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
}'
import os
import requests
response = requests.post(
"https://api.brightdata.com/search/company",
headers={
"Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
"Content-Type": "application/json",
},
json={
"mode": "smart",
"query": "Fraud-detection software providers with an office in the United Kingdom",
"limit": 3,
"view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
},
)
print(response.text)
const response = await fetch("https://api.brightdata.com/search/company", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"mode": "smart",
"query": "Fraud-detection software providers with an office in the United Kingdom",
"limit": 3,
"view": { "fields": ["name", "industry", "specialties", "offices_country_codes", "website"] }
}),
});
console.log(await response.text());
{
"req_id": "rb4c207d88e7e43a7a0dce6da7a06292a",
"source": "linkedin_company",
"meta": {
"coverage_percent": 100,
"matched": 828,
"offset": 0,
"limit": 3
},
"documents": [
{
"bright_id": "ea4950408cd68b5abd76383b8a7c8a23c0600616559ad51253b897164bda60f3",
"data": {
"name": "Resistant AI - Fraud Detection",
"industry": "Financial Services",
"specialties": "Document Verification, Anti Fraud Software, Spot Fake Bank Statements, ID Verification, Fake Document Detection, Document Fraud Detection, Fraud Prevention, Machine Learning, Artificial Intelligence, Financial Fraud, Document Forgery, KYC, KYB, Onboarding, Loan Fraud, AI Detector, Tenant Screening, Loan Underwriting, Employment Verification, Fraud Detection in Insurance Claims, AML, and Transaction Monitoring",
"offices_country_codes": [
"CZ",
"GB",
"US"
],
"website": "https://resistant.ai/"
}
}
]
}
如何按曾任雇主查找人物
要查找曾在 Microsoft 工作、现已离开的美国工程经理,请把针对past_company_names 的 text 条件与针对 current_company_name 的 not 条件组合起来。这个例子请使用结构化查询:测试中,自然语言形式能找到曾在 Microsoft 工作的人,但没有排除目前仍在 Microsoft 工作的人。past_company_names 只列出雇主而不含日期,因此结果只能说明此人曾在 Microsoft 工作,而不能说明是何时。
两个雇主条件都设置了 mode: "all",与按办公地点查找的示例相同。not 条件会排除当前雇主仍是 Microsoft 的档案:
示例请求
curl --request POST "https://api.brightdata.com/search/people" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "ludicrous",
"query": {
"and": [
{ "text": { "current_title": { "value": "engineering manager", "mode": "all" } } },
{ "text": { "past_company_names": { "value": "Microsoft", "mode": "all" } } },
{ "not": { "text": { "current_company_name": { "value": "Microsoft", "mode": "all" } } } },
{ "equals": { "country_code": "US" } }
]
},
"limit": 3,
"view": { "fields": ["current_title", "current_company_name", "past_company_names", "country_code"] }
}'
import os
import requests
response = requests.post(
"https://api.brightdata.com/search/people",
headers={
"Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
"Content-Type": "application/json",
},
json={
"mode": "ludicrous",
"query": {
"and": [
{ "text": { "current_title": { "value": "engineering manager", "mode": "all" } } },
{ "text": { "past_company_names": { "value": "Microsoft", "mode": "all" } } },
{ "not": { "text": { "current_company_name": { "value": "Microsoft", "mode": "all" } } } },
{ "equals": { "country_code": "US" } }
]
},
"limit": 3,
"view": { "fields": ["current_title", "current_company_name", "past_company_names", "country_code"] }
},
)
print(response.text)
const response = await fetch("https://api.brightdata.com/search/people", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"mode": "ludicrous",
"query": {
"and": [
{ "text": { "current_title": { "value": "engineering manager", "mode": "all" } } },
{ "text": { "past_company_names": { "value": "Microsoft", "mode": "all" } } },
{ "not": { "text": { "current_company_name": { "value": "Microsoft", "mode": "all" } } } },
{ "equals": { "country_code": "US" } }
]
},
"limit": 3,
"view": { "fields": ["current_title", "current_company_name", "past_company_names", "country_code"] }
}),
});
console.log(await response.text());
{
"req_id": "r8aa70e91316e44e69ffd193c74070a8c",
"source": "linkedin_people",
"meta": {
"coverage_percent": 100,
"matched": 887,
"offset": 0,
"limit": 3
},
"documents": [
{
"bright_id": "2c592bb9eb4910423f189ed3e6212195ffc987386b5d047ce3184ecdc79a0670",
"data": {
"current_title": "Engineering Manager",
"current_company_name": "Google",
"past_company_names": "Microsoft; Microsoft Corporation",
"country_code": "US"
}
}
]
}
如何运行多步搜索
同时包含公司条件和人物条件的问题,需要不止一次 Business Search 请求。人物搜索只能按人物可搜索字段筛选,例如current_title 和 current_company_name。公司搜索按公司可搜索字段筛选,例如融资和总部。人物记录可以在视图中返回 current_company_funding_raised,但人物搜索无法按该字段筛选。
分三步运行搜索:
- 运行公司搜索,满足公司条件,并收集公司名称。
- 运行人物搜索,满足人物条件,并限定在这些公司名称范围内。
- 只保留当前雇主属于第 1 步公司之一的档案。
前提条件
- 一个具有 Business Search 访问权限的 Bright Data API 密钥,存储在
BRIGHTDATA_API_KEY环境变量中。参见 Business Search 快速入门 - Python 标签页需要安装了
requests包的 Python 3;Node.js 标签页需要 Node.js 18 或更高版本
第 1 步:查找公司
在 Instant 模式下,把问题中与公司相关的部分作为一句话发送。视图请求name(第 2 步和第 3 步用它把人物匹配到公司),以及 headquarters_city 和 funding_raised,便于逐一核对每家公司是否符合问题:
curl --request POST "https://api.brightdata.com/search/company" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "instant",
"query": "Technology companies headquartered in San Francisco whose latest funding round was between $1 and $2 million",
"limit": 100,
"view": { "fields": ["name", "headquarters_city", "funding_raised"] }
}'
import os
import requests
API = "https://api.brightdata.com/search"
HEADERS = {
"Authorization": f"Bearer {os.environ['BRIGHTDATA_API_KEY']}",
"Content-Type": "application/json",
}
response = requests.post(
f"{API}/company",
headers=HEADERS,
json={
"mode": "instant",
"query": "Technology companies headquartered in San Francisco whose latest funding round was between $1 and $2 million",
"limit": 100,
"view": {"fields": ["name", "headquarters_city", "funding_raised"]},
},
)
response.raise_for_status()
companies = {
doc["data"]["name"]
for doc in response.json()["documents"]
if "name" in doc["data"]
and "san francisco" in doc["data"].get("headquarters_city", "").lower()
}
print(f"{len(companies)} companies found")
const API = "https://api.brightdata.com/search";
const HEADERS = {
Authorization: `Bearer ${process.env.BRIGHTDATA_API_KEY}`,
"Content-Type": "application/json",
};
const companyResponse = await fetch(`${API}/company`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({
mode: "instant",
query: "Technology companies headquartered in San Francisco whose latest funding round was between $1 and $2 million",
limit: 100,
view: { fields: ["name", "headquarters_city", "funding_raised"] },
}),
});
if (!companyResponse.ok) throw new Error(await companyResponse.text());
const companies = new Set();
for (const doc of (await companyResponse.json()).documents) {
const city = (doc.data.headquarters_city ?? "").toLowerCase();
if (doc.data.name && city.includes("san francisco")) companies.add(doc.data.name);
}
console.log(`${companies.size} companies found`);
headquarters_city 包含 San Francisco 的公司。Instant 最多返回前 100 条匹配结果。如需一份按每家公司与该句子的契合程度排序的较短列表,请以 "mode": "smart" 和 "limit": 10 发送同样的请求体。Smart 每次搜索的费用更高。参见 Business Search 价格。
第 2 步:搜索这些公司的人物
在 Ludicrous 模式下发送人物搜索,因为此时的输入是第 1 步得到的公司名称列表,而不是一句话。每次请求将人物条件(本例中为 CEO 职位)与最多 10 个公司名称组合,作为current_company_name 上的 or 条件:
curl --request POST "https://api.brightdata.com/search/people" \
--header "Authorization: Bearer $BRIGHTDATA_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"mode": "ludicrous",
"query": {
"and": [
{
"or": [
{ "text": { "current_title": "CEO" } },
{ "text": { "current_title": { "value": "chief executive officer", "mode": "all" } } }
]
},
{
"or": [
{ "text": { "current_company_name": { "value": "COMPANY_NAME_1", "mode": "all" } } },
{ "text": { "current_company_name": { "value": "COMPANY_NAME_2", "mode": "all" } } }
]
}
]
},
"limit": 100,
"view": { "fields": ["current_title", "current_company_name"] }
}'
ceo_title = {
"or": [
{"text": {"current_title": "CEO"}},
{"text": {"current_title": {"value": "chief executive officer", "mode": "all"}}},
]
}
names = sorted(companies)
people = {}
for start in range(0, len(names), 10):
batch = names[start:start + 10]
response = requests.post(
f"{API}/people",
headers=HEADERS,
json={
"mode": "ludicrous",
"query": {
"and": [
ceo_title,
{
"or": [
{"text": {"current_company_name": {"value": name, "mode": "all"}}}
for name in batch
]
},
]
},
"limit": 100,
"view": {"fields": ["current_title", "current_company_name"]},
},
)
response.raise_for_status()
for doc in response.json()["documents"]:
people[doc["bright_id"]] = doc["data"]
print(f"{len(people)} candidate profiles found")
const ceoTitle = {
or: [
{ text: { current_title: "CEO" } },
{ text: { current_title: { value: "chief executive officer", mode: "all" } } },
],
};
const names = [...companies];
const people = new Map();
for (let start = 0; start < names.length; start += 10) {
const batch = names.slice(start, start + 10);
const peopleResponse = await fetch(`${API}/people`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({
mode: "ludicrous",
query: {
and: [
ceoTitle,
{ or: batch.map((name) => ({ text: { current_company_name: { value: name, mode: "all" } } })) },
],
},
limit: 100,
view: { fields: ["current_title", "current_company_name"] },
}),
});
if (!peopleResponse.ok) throw new Error(await peopleResponse.text());
for (const doc of (await peopleResponse.json()).documents) {
people.set(doc.bright_id, doc.data);
}
}
console.log(`${people.size} candidate profiles found`);
bright_id 为键保存结果,因此被两个批次同时返回的档案只保留一次。在 cURL 标签页中,把 COMPANY_NAME_1 和 COMPANY_NAME_2 替换为第 1 步得到的公司名称,每个名称添加一个条件。每次请求都是一次单独计费的搜索,因此 100 家公司共需 11 次搜索。
第 3 步:保留公司匹配的档案
只保留current_company_name 与第 1 步中某个公司名称完全一致的档案。使用 cURL 时,请对比第 1 步和第 2 步响应中的这两个值:
ceos = [p for p in people.values() if p.get("current_company_name") in companies]
for person in ceos:
print(f"{person['current_title']} at {person['current_company_name']}")
const ceos = [...people.values()].filter((p) => companies.has(p.current_company_name));
for (const person of ceos) {
console.log(`${person.current_title} at ${person.current_company_name}`);
}
current_company_name 是文本字段,条件会匹配公司名称包含这些词的所有档案:Acme 也会匹配 Acme Robotics。按完整名称比对会剔除这些档案,也会剔除没有 current_company_name 的档案。两次搜索没有共同的标识符:公司记录的 company_id 与人物记录的 current_company_id 是不同的值,因此名称是两边都会返回的唯一字段。
使用名单前请先核对。针对 current_title 的 text 条件也会匹配仅包含 CEO 的职位,例如 Assistant to CEO。同一个公司名称也可能属于不止一家公司,按名称匹配无法区分它们。