高德商家手机电话号码采集工具,可采集地址坐标手机号码提取软件

简介: 这是一套基于高德地图API的商家信息采集解决方案,提供核心代码与功能实现。通过高德Place API,合法合规地批量采集商家基础信息

下载地址:https://www.pan38.com/share.php?code=pvvmX 提取码:7889

基于高德地图API实现商家信息采集的完整解决方案,包含核心代码实现和功能代码,当然我们这个是通过公开接口采集的,并不是破解或者逆向接口的哦,所以采集的数据都是合法合规的,只不过我们实现了批量化而是。

核心功能模块:

通过高德Place API实现商家基础信息采集911
支持多页翻页采集和异常处理
自动获取经纬度坐标和详细联系方式
数据字段说明:
名称(name)、详细地址(address)
经纬度坐标(location)
联系电话(tel/detail_tel)2
行政区划信息(pname/cityname/adname)
行业分类(type)

import requests
import pandas as pd
from tqdm import tqdm

class AmapScraper:
def init(self, api_key):
self.api_key = api_key
self.base_url = "https://restapi.amap.com/v3/place/text"
self.headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
}

def fetch_poi_data(self, keywords, city=None, pages=10):
    """获取POI数据"""
    all_data = []
    for page in tqdm(range(1, pages+1)):
        params = {
            'key': self.api_key,
            'keywords': keywords,
            'city': city,
            'offset': 25,
            'page': page,
            'extensions': 'all',
            'output': 'json'
        }
        try:
            response = requests.get(
                self.base_url, 
                params=params,
                headers=self.headers,
                timeout=10
            )
            data = response.json()
            if data['status'] == '1':
                all_data.extend(data['pois'])
        except Exception as e:
            print(f"Error fetching page {page}: {str(e)}")
    return all_data

def parse_poi_info(self, pois):
    """解析POI详细信息"""
    result = []
    for poi in tqdm(pois):
        detail_url = "https://restapi.amap.com/v3/place/detail"
        params = {
            'key': self.api_key,
            'id': poi['id'],
            'extensions': 'all'
        }
        try:
            resp = requests.get(detail_url, params=params, timeout=5)
            detail = resp.json()
            if detail['status'] == '1':
                info = {
                    'name': poi['name'],
                    'address': poi['address'],
                    'location': poi['location'],
                    'tel': poi.get('tel', ''),
                    'detail_tel': detail['pois'][0].get('tel', ''),
                    'type': poi['type'],
                    'pname': poi['pname'],
                    'cityname': poi['cityname'],
                    'adname': poi['adname']
                }
                result.append(info)
        except Exception as e:
            print(f"Error parsing {poi['id']}: {str(e)}")
    return result

def save_to_excel(self, data, filename):
    """保存到Excel文件"""
    df = pd.DataFrame(data)
    df.to_excel(filename, index=False, encoding='utf-8-sig')
    print(f"数据已保存到 {filename}")

if name == "main":

# 替换为您的高德API Key
scraper = AmapScraper(api_key="YOUR_AMAP_API_KEY")  

# 采集餐饮类商家(可修改关键词)
pois = scraper.fetch_poi_data("餐饮", city="北京", pages=5)

# 解析详细信息
detailed_data = scraper.parse_poi_info(pois)

# 保存结果
scraper.save_to_excel(detailed_data, "amap_business_data.xlsx")

[amap]
api_key = YOUR_AMAP_API_KEY
default_city = 北京
default_keywords = 餐饮
max_pages = 10
output_format = excel
timeout = 10
代码语言:txt
AI代码解释

import concurrent.futures
import logging
from queue import Queue
import pandas as pd
import requests

class EnhancedAmapScraper:
def init(self, api_key, max_workers=5):
self.api_key = api_key
self.base_url = "https://restapi.amap.com/v3/place/text"
self.session = requests.Session()
self.logger = self._setup_logger()
self.max_workers = max_workers

def _setup_logger(self):
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.INFO)
    handler = logging.FileHandler('amap_scraper.log')
    formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    return logger

def _make_request(self, params):
    try:
        resp = self.session.get(
            self.base_url,
            params=params,
            timeout=10,
            headers={'User-Agent': 'Mozilla/5.0'}
        )
        resp.raise_for_status()
        return resp.json()
    except Exception as e:
        self.logger.error(f"Request failed: {str(e)}")
        return None

def fetch_pois(self, keywords, city=None, pages=10):
    work_queue = Queue()
    result_queue = Queue()

    for page in range(1, pages+1):
        work_queue.put({
            'keywords': keywords,
            'city': city,
            'page': page
        })

    with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor:
        futures = [
            executor.submit(
                self._worker,
                work_queue,
                result_queue
            ) for _ in range(self.max_workers)
        ]
        concurrent.futures.wait(futures)

    return list(result_queue.queue)

def _worker(self, work_queue, result_queue):
    while not work_queue.empty():
        try:
            task = work_queue.get_nowait()
            params = {
                'key': self.api_key,
                'keywords': task['keywords'],
                'city': task['city'],
                'page': task['page'],
                'offset': 20,
                'extensions': 'all'
            }
            data = self._make_request(params)
            if data and data['status'] == '1':
                for poi in data['pois']:
                    result_queue.put(poi)
        except Exception as e:
            self.logger.error(f"Worker error: {str(e)}")
        finally:
            work_queue.task_done()

def get_poi_details(self, poi_ids):
    detail_url = "https://restapi.amap.com/v3/place/detail"
    results = []

    with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor:
        futures = []
        for poi_id in poi_ids:
            futures.append(executor.submit(
                self._get_single_detail,
                detail_url,
                poi_id
            ))

        for future in concurrent.futures.as_completed(futures):
            result = future.result()
            if result:
                results.append(result)

    return results

def _get_single_detail(self, url, poi_id):
    try:
        resp = self.session.get(
            url,
            params={
                'key': self.api_key,
                'id': poi_id,
                'extensions': 'all'
            },
            timeout=5
        )
        data = resp.json()
        if data['status'] == '1':
            return {
                'id': poi_id,
                'name': data['pois'][0]['name'],
                'tel': data['pois'][0].get('tel', ''),
                'address': data['pois'][0]['address'],
                'location': data['pois'][0]['location'],
                'photos': [p['url'] for p in data['pois'][0].get('photos', [])]
            }
    except Exception as e:
        self.logger.error(f"Detail fetch error for {poi_id}: {str(e)}")
    return None

if name == "main":
scraper = EnhancedAmapScraper(api_key="YOUR_API_KEY")

# 采集餐饮类POI
pois = scraper.fetch_pois("餐饮", city="北京", pages=5)

# 获取详细信息
poi_ids = [poi['id'] for poi in pois]
details = scraper.get_poi_details(poi_ids[:50])  # 限制50条测试

# 保存结果
pd.DataFrame(details).to_excel("amap_details.xlsx", index=False)
相关文章
|
24天前
|
并行计算 计算机视觉 流计算
照片生成眨眼张嘴的视频软件,制作眨眼睛张嘴图软件,手机制作人脸眨眼张嘴
这是一套基于Python的人脸动画生成系统,功能完整且模块化设计。项目利用dlib与face-alignment库实现精准人脸关键点检测,结合Delaunay三角剖分技术完成图像变形
|
2天前
|
API 数据安全/隐私保护 开发者
企业微信自动加好友软件,导入手机号批量添加微信好友,python版本源码分享
代码展示了企业微信官方API的合规使用方式,包括获取access_token、查询部门列表和创建用户等功能
|
2天前
|
存储 API 数据库
自动发短信的软件,批量自动群发短信,手机号电话号生成器【python框架】
这个短信群发系统包含以下核心功能: 随机手机号生成器(支持中国号码) 批量短信发送功能(使用Twilio API)
|
2天前
|
API 数据安全/隐私保护 Python
批量发短信的软件,自动群发短信批量工具,手机号电话生成脚本插件【python】
该工具包含三个核心模块:短信发送核心功能、配置管理系统和命令行界面。使用时需先配置API密钥和短信模板
|
1天前
|
数据安全/隐私保护 计算机视觉 Python
人脸识别图片眨眼生成器,手机制作人脸眨眼张嘴, 代替真人刷脸软件
代码实现了基于面部特征点的人脸动画生成,包括眨眼和张嘴动作。它使用dlib进行人脸检测和特征点定位
|
2天前
|
Java API 数据安全/隐私保护
手机无人直播手机用啥软件,抖音快手无人直播工具,jar代码分享
这个无人直播系统包含视频处理、直播推流和自动化控制三个核心模块。使用mvn package命
|
12天前
|
前端开发 数据安全/隐私保护
股票持仓截图生成器手机版, 股票持仓图生成器免费,交割单生成器制作工具
代码实现了一个完整的股票持仓截图生成器,包含数据模拟、表格绘制、汇总计算和水印添加功能。
|
22天前
|
Android开发
安卓硬改一键新机工具,一键修改手机型号,串号网卡Imei、sn码【仅供学习参考】
声明部分:仅供学习参考使用,基于Xposed框架实现的设备信息伪装模块的完整代码,包含多个功能模块:
|
24天前
|
算法 Python
让照片眨眼张嘴的软件免费,照片摇头眨眼张嘴动图,手机制作人脸眨眼张嘴
本项目提供手机端从代码到开发的完整实现路径,包含人脸关键点检测与动画生成。结合先进算法如First Order Motion Model可进一步优化效果,相关开源项目可在GitHub获取。
|
25天前
|
存储 数据采集 文字识别
美团商家电话采集工具,可提取美团商户联系方式、地址、手机号、评分【autojs脚本版】
这是一款基于安卓无障碍服务的美团商家数据采集工具,包含主流程控制、页面解析、电话提取和工具函数四大模块。通过控件层级定位与OCR技术实现数据抓取,支持自动翻页及异常处理,最终以CSV格式存储结果。

热门文章

最新文章