123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace Ku\Spider;
- use Dever;
- class Youzan
- {
- public function rule()
- {
- return array
- (
- 'pic' => '<img src="(.*?)" alt="(.*?)"/>',
- 'name' => '<h3 class="goods-title">(.*?)</h3>',
- 'price' => '<em class="goods-rmb">¥</em>(.*?)</strong>',
- );
- }
- public function link($link)
- {
- if (strpos($link, 'h5.youzan.com')) {
- $temp = explode('/goods/', $link);
- $id = $temp[1];
- $link = 'https://detail.youzan.com/show/goods?alias=' . $id;
- }
- return $link;
- }
- public function replace($key, $data)
- {
- if ($key == 'price') {
- $data = str_replace('<span class="goods-activity">限时折扣</span>', '', $data);
- }
-
- return $data;
- }
- }
|