Compare commits

...

13 Commits

Author SHA1 Message Date
Jaeger(黄杰)
894fb4344e
Merge pull request from maxiaozhi/master
正则匹配成功时才替换掉html
2021-08-08 13:04:55 +08:00
lion
e4fc716acd 正则匹配成功时才替换掉html 2021-07-18 23:37:35 +08:00
Jaeger(黄杰)
39dc0ca9c6
Merge pull request from maxiaozhi/patch-1
Fix the matching exception
2021-07-05 14:07:58 +08:00
maxiaozhi
ef0a2efd4f
Fix the matching exception
Fix the matching exception when the page contains multiple tags prefixed with head (for example: < head >, < header >)
2021-07-05 13:51:24 +08:00
huangjie
5953daac54 update collect 2020-12-14 10:39:28 +08:00
huangjie
465c6aefc7 update collect 2020-09-27 17:41:44 +08:00
Jaeger(黄杰)
92cb319d44
Update README-ZH.md 2020-07-18 13:06:29 +08:00
Jaeger(黄杰)
cbf3e0fcad
Update README.md 2020-07-18 13:05:59 +08:00
Jaeger(黄杰)
cfa2d94a79
Update FUNDING.yml 2020-07-17 13:20:49 +08:00
Jaeger(黄杰)
47a444bf9e
Create FUNDING.yml 2020-07-17 13:08:44 +08:00
Jaeger
85903fa9b5 feat: rules add attrs 2020-04-03 20:16:00 +08:00
Jaeger(黄杰)
e527c637c7
Merge pull request from jae-jae/develop
replace collect()
2020-04-03 04:55:27 -05:00
Jaeger
f0a9798925 replace collect() 2020-04-03 17:33:32 +08:00
9 changed files with 38 additions and 16 deletions

12
.github/FUNDING.yml vendored Normal file

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: querylist # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

3
.gitignore vendored

@ -1,4 +1,5 @@
/vendor/
.idea/
composer.lock
.DS_Store
.DS_Store
*.cache

@ -29,7 +29,7 @@
- .....
## 环境要求
- PHP >= 7.0
- PHP >= 7.1
> 如果你的PHP版本还停留在PHP5或者不会使用Composer,你可以选择使用QueryList3,QueryList3支持php5.3以及手动安装。
QueryList3 文档:http://v3.querylist.cc
@ -306,4 +306,4 @@ $ql->curlMulti([
Jaeger <JaegerCode@gmail.com>
## Lisence
QueryList is licensed under the license of MIT. See the LICENSE for more details.
QueryList is licensed under the license of MIT. See the LICENSE for more details.

@ -31,7 +31,7 @@ Through plug-ins you can easily implement things like:
- .....
## Requirements
- PHP >= 7.0
- PHP >= 7.1
## Installation
By Composer installation:
@ -301,4 +301,4 @@ Jaeger <JaegerCode@gmail.com>
If this library is useful for you, say thanks [buying me a beer :beer:](https://www.paypal.me/jaepay)!
## Lisence
QueryList is licensed under the license of MIT. See the LICENSE for more details.
QueryList is licensed under the license of MIT. See the LICENSE for more details.

@ -6,9 +6,9 @@
"require": {
"PHP":">=7.1",
"jaeger/phpquery-single": "^1",
"tightenco/collect": "^5",
"jaeger/g-http": "^1.1",
"ext-dom": "*"
"ext-dom": "*",
"tightenco/collect": ">5.0"
},
"suggest":{

@ -7,6 +7,7 @@
namespace QL;
use Closure;
use Tightenco\Collect\Support\Collection;
class Config
{
@ -20,8 +21,8 @@ class Config
*/
public function __construct()
{
$this->plugins = collect();
$this->binds = collect();
$this->plugins = new Collection();
$this->binds = new Collection();
}

@ -9,6 +9,7 @@ namespace QL\Dom;
use phpDocumentor\Reflection\Types\Null_;
use phpQueryObject;
use Tightenco\Collect\Support\Collection;
/**
* Class Elements
@ -191,7 +192,7 @@ class Elements
*/
public function map($callback)
{
$collection = collect();
$collection = new Collection();
$this->elements->each(function ($dom) use (& $collection, $callback) {
$collection->push($callback(new self(pq($dom))));
});

@ -125,8 +125,8 @@ class Query
*/
public function removeHead()
{
$html = preg_replace('/<head.+?>.+<\/head>/is', '<head></head>', $this->html);
$this->setHtml($html);
$html = preg_replace('/(<head>|<head\s+.+?>).+?<\/head>/is', '<head></head>', $this->html);
$html && $this->setHtml($html);
return $this->ql;
}
@ -147,7 +147,7 @@ class Query
{
if (is_callable($callback)) {
if (empty($this->range)) {
$data = collect($callback($data->all(), null));
$data = new Collection($callback($data->all(), null));
} else {
$data = $data->map($callback);
}
@ -178,7 +178,7 @@ class Query
}
}
return collect($data);
return new Collection($data);
}
protected function extractContent(phpQueryObject $pqObj, $ruleName, $rule)
@ -209,7 +209,13 @@ class Query
})->all();
break;
default:
$content = $pqObj->attr($rule['attr']);
if(preg_match('/attr\((.+)\)/', $rule['attr'], $arr)) {
$content = $pqObj->attr($arr[1]);
} elseif (preg_match('/attrs\((.+)\)/', $rule['attr'], $arr)) {
$content = (new Elements($pqObj))->attrs($arr[1])->all();
} else {
$content = $pqObj->attr($rule['attr']);
}
break;
}

@ -14,6 +14,7 @@ use Closure;
use QL\Providers\HttpServiceProvider;
use QL\Providers\PluginServiceProvider;
use QL\Providers\SystemServiceProvider;
use Tightenco\Collect\Support\Collection;
class Kernel
{
@ -34,7 +35,7 @@ class Kernel
public function __construct(QueryList $ql)
{
$this->ql = $ql;
$this->binds = collect();
$this->binds = new Collection();
}
public function bootstrap()