---
title: "PHP 正则采集百度的图片地址"
author: "onestopweb"
date: "2017-11-16T16:48:22Z"
tags: []
categories: ["编程语言"]
slug: "php"
draft: false
lastmod: "2017-11-16T16:48:22Z"
id: 2399975
url: "https://onestopweb.iteye.com/blog/2399975"
---

```
<?php
$brand = '风景';
 
$url = "http://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=index&fr=&sf=1&fmq=&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word={$brand}&oq={$brand}&rsp=-1";
$content = file_get_contents($url);
preg_match_all('/objURL":"(.*?)",/',$content,$match);
print_r($match);
```

 

效果图：  
![](http://dl2.iteye.com/upload/attachment/0127/8281/bc06a4d7-c3d1-3630-9d9a-c4e2ede36be0.jpg)