Baidu Scraper
Spider read baidu.com in 6.8 s without a browser and returned 367 lines of clean markdown.
### 开发者热搜3. `<artifactId>httpclient</artifactId>`7. `<groupId>com.fasterxml.jackson.core</groupId>`8. `<artifactId>jackson-databind</artifactId>`### 2. 认证配置2. `import javax.crypto.spec.SecretKeySpec;`6. `private static final String ALGORITHM = "HmacSHA256";`8. `public static String generateSign(String secretKey, String data) {`10. `Mac mac = Mac.getInstance(ALGORITHM);`11. `SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), ALGORITHM);`13. `byte[] hash = mac.doFinal(data.getBytes());`14. `return Base64.getEncoder().encodeToString(hash);`16. `throw new RuntimeException("Signature generation failed", e);`## 三、核心实现步骤### 1. 请求构建与发送1. `import org.apache.http.client.methods.HttpGet;`2. `import org.apache.http.impl.client.CloseableHttpClient;`3. `import org.apache.http.impl.client.HttpClients;`4. `import org.apache.http.util.EntityUtils;`6. `public class BaiduSearchClient {`7. `private static final String BASE_URL = "https://api.baidu.com/search/v1";`11. `public BaiduSearchClient(String apiKey, String secretKey) {`13. `this.secretKey = secretKey;`16. `public String search(String query, int page, int size) throws Exception {`17. `String timestamp = String.valueOf(System.currentTimeMillis());`18. `String signData = apiKey + query + page + size + timestamp;`19. `String sign = AuthUtil.generateSign(secretKey, signData);`21. `String url = BASE_URL + "?q=" + URLEncoder.encode(query, "UTF-8")`28. `try (CloseableHttpClient client = HttpClients.createDefault()) {`29. `HttpGet request = new HttpGet(url);`30. `return client.execute(request, httpResponse -> `31. `EntityUtils.toString(httpResponse.getEntity()));` The same call, in code.
The capture above came back as markdown. These examples add a key, so you get browser rendering, proxies, and concurrency on baidu.com.
import { SpiderBrowser } from "spider-browser";
const spider = new SpiderBrowser({
apiKey: process.env.SPIDER_API_KEY!,
});
await spider.connect();
const page = spider.page!;
await page.goto("https://www.baidu.com/s?wd=web+scraping");
// No selectors, no schema. Spider reads the page and names the fields.
const data = await page.scrape();
console.log(data);
await spider.close(); import { SpiderBrowser } from "spider-browser";
const spider = new SpiderBrowser({
apiKey: process.env.SPIDER_API_KEY!,
stealth: 2,
});
await spider.connect();
const page = spider.page!;
await page.goto("https://www.baidu.com/s?wd=web+scraping");
await page.content();
const data = await page.evaluate(`(() => {
const results = [];
document.querySelectorAll(".result.c-container").forEach((el, i) => {
const title = el.querySelector("h3 a")?.textContent?.trim();
const url = el.querySelector("h3 a")?.getAttribute("href");
const snippet = el.querySelector("[class*='c-abstract'], h3 ~ div, h3 ~ span")?.textContent?.trim();
if (title) results.push({ position: i + 1, title, url, snippet });
});
return JSON.stringify({ total: results.length, results: results.slice(0, 10) });
})()`);
console.log(JSON.parse(data));
await spider.close(); Ready for volume? Get an API key →
Fields you can pull.
Spider names these from the page. The capture above came back as markdown; the same
call with return_format: "json" returns them as keys.
What baidu.com costs to scrape.
The capture above cost $0.000462 to fetch. Pricing is $1 per GB of pre-transformation bandwidth plus $0.001 per CPU minute, so a page like this one lands at a fraction of a cent. Failed requests are billed at $0.
- Free balance on signup
- No card required to test
- Balance never expires
Run it keyless, no account
More Search scrapers.
Google Scraper
Extract Google Search results, knowledge panels, featured snippets, People Also Ask, and full SERP data programmatically. Geo-targeted proxies from 195+ countries for localized results.
Google Play Scraper
Extract app listings, ratings, reviews, download counts, and developer info from Google Play Store.
Google Maps Scraper
Extract business listings, reviews, ratings, contact info, hours, and location data from Google Maps. Full browser rendering handles map interfaces and infinite scroll.
Start scraping baidu.com.
You already have the call. A key raises the rate limit and turns on browser rendering, proxies, and concurrency. Balance never expires, and top-ups go through secure checkout.