How to Scrape Baidu Aiqicha Data with Python: A Step‑by‑Step Guide

This article walks through a real‑world Python web‑scraping case, explaining the problem, revealing hidden request URLs, showing the complete code, and demonstrating how to retrieve and verify data from Baidu's Aiqicha platform.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Scrape Baidu Aiqicha Data with Python: A Step‑by‑Step Guide

Introduction

A fan asked a detailed question about scraping a website similar to Aiqicha, prompting a deep dive into the issue.

1. Idea

Initially the author tried simple packet capture but couldn't find the response data in the network tabs, leading to confusion.

2. Analysis

By examining the code shared by another expert, a hidden URL parameter was discovered, which is not visible in the page source. Capturing the request revealed the data.

Changing the keyword in the URL from a generic term to the specific target (e.g., "Shanghai surgical instrument factory") allowed the data to be retrieved.

3. Code

# -*- coding: utf-8 -*-
import requests
import user_agent
from urllib import parse

def search(key_word):
    for page_num in range(1, 2):
        url = f'https://aiqicha.baidu.com/s/advanceFilterAjax?q={parse.quote(key_word)}&t=&p={str(page_num)}&s=10&o=0&f=%7B%7D'
        headers = {
            'User-Agent': user_agent.generate_user_agent(),
            'Referer': 'https://aiqicha.baidu.com/s?q=%E6%95%B0%E6%8D%AE%E5%BA%93&t=0',
        }
        print(url)
        response = requests.get(url=url, headers=headers)
        print(response)
        print(response.json())
        # break

if __name__ == '__main__':
    search('上海手术器械厂')

Replace the keyword with any term you wish to search.

4. Results

The script prints the request URL and the JSON response, confirming that the data matches the original webpage screenshot.

Conclusion

This practical example demonstrates a "reverse‑engineer" approach to obtain data from pages that hide their API calls, offering a useful technique for similar scraping challenges. Alternatives like Selenium are also possible, albeit slower.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonTutorialBaiduweb-scrapingdata-mining
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.