FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
-remove-phpquery/cli/phpquery at master · cmprecycle/-remove-phpquery · GitHub
cmprecycle
-remove-phpquery
Repository navigation
Code
Issues
160
(160)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
-remove-phpquery
/
cli
/
phpquery
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
68 lines (68 loc) · 1.89 KB
Breadcrumbs
-remove-phpquery
/
cli
/
phpquery
Copy path
File metadata and controls
executable file
·
68 lines (68 loc) · 1.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env php
<?php
if
(!
isset
(
$
argv
[
1
]) ||
$
argv
[
1
] ==
'
help
'
||
$
argv
[
1
] ==
'
--help
'
||
$
argv
[
1
] ==
'
-h
'
)
die
(
"
Usage:
phpquery URL --method1 arg1 arg2 argN --method2 arg1 arg2 argN ...
Example:
phpquery 'http://localhost' --find 'div > p' --contents
Pipe:
cat index.html | phpquery --find 'div > p' --contents
Docs:
http://code.google.com/p/phpquery/wiki/
\n"
);
/* ALL-IN-ONE-SECTION-START */
set_include_path
(
get_include_path
()
.
'
:
'
.
'
/usr/lib/phpquery
'
.
'
:
'
.
realpath
(
dirname
(
__FILE__
).
'
/../phpQuery
'
)
);
require_once
(
'
phpQuery.php
'
);
/* ALL-IN-ONE-SECTION-END */
//phpQuery::$debug = true;
//var_dump($argv);
if
(
isset
(
$
argv
[
1
]) &&
parse_url
(
$
argv
[
1
],
PHP_URL_HOST
)) {
if
(@
include_once
(
'
Zend/Http/Client.php
'
)) {
// use Ajax if possible
phpQuery::
ajaxAllowURL
(
$
argv
[
1
]);
// TODO support contentType passing (from response headers)
phpQuery::
get
(
$
argv
[
1
],
new
Callback
(
'
phpQueryCli
'
,
new
CallbackParam
,
array_slice
(
$
argv
,
2
))
);
}
else
{
// use file wrapper when no Ajax
phpQueryCli
(
file_get_contents
(
$
argv
[
1
]),
array_slice
(
$
argv
,
2
));
}
}
else
if
(
feof
(
STDIN
) ===
false
) {
$
markup
=
''
;
while
(!
feof
(
STDIN
))
$
markup
.=
fgets
(
STDIN
,
4096
);
phpQueryCli
(
$
markup
,
array_slice
(
$
argv
,
1
));
}
else
{
phpQueryCli
(
$
argv
[
1
],
array_slice
(
$
argv
,
2
));
}
function
phpQueryCli
(
$
markup
,
$
callQueue
) {
$
pq
= phpQuery::
newDocument
(
$
markup
);
$
method
=
null
;
$
params
=
array
();
foreach
(
$
callQueue
as
$
param
) {
if
(
strpos
(
$
param
,
'
--
'
) ===
0
) {
if
(
$
method
) {
$
pq
=
call_user_func_array
(
array
(
$
pq
,
$
method
),
$
params
);
}
$
method
=
substr
(
$
param
,
2
);
// delete --
$
params
=
array
();
}
else
{
$
param
=
str_replace
(
'
\n
'
,
"\n"
,
$
param
);
$
params
[] =
strtolower
(
$
param
) ==
'
null
'
?
null
:
$
param
;
}
}
if
(
$
method
)
$
pq
=
call_user_func_array
(
array
(
$
pq
,
$
method
),
$
params
);
if
(
is_array
(
$
pq
))
foreach
(
$
pq
as
$
v
)
print
$
v
;
else
print
$
pq
.
"\n"
;
//var_dump($pq);
}
?>
Back
|
FazBrowse Home
|
New Git URL