Skip to content

Commit 348cb47

Browse files
Update and rename webscraper.php to webparser.php
1 parent a765823 commit 348cb47

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

webscraper.php renamed to webparser.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ private function convertToXPath($query)
4242

4343
$xpath = preg_replace(
4444
[
45+
"/\n{1,}/",
46+
"/\s{2,}/",
4547
"/([^,])\s/",
4648
"/\/>\//",
4749

@@ -75,6 +77,8 @@ private function convertToXPath($query)
7577
"/^\[/",
7678
],
7779
[
80+
"",
81+
" ",
7882
"$1/",
7983
"/",
8084

@@ -141,6 +145,20 @@ public function removeAttribute($attr)
141145
$this->obj = null;
142146
}
143147

148+
149+
public function hasAttribute($attr, $val)
150+
{
151+
152+
foreach($this->obj as $item)
153+
{
154+
$attrs = $item->getAttribute("$attr");
155+
}
156+
157+
$bool = (preg_match("/".preg_quote($val)."/", $attrs)) ? true : false;
158+
159+
return $bool;
160+
}
161+
144162
public function href($url)
145163
{
146164

@@ -199,19 +217,6 @@ public function hasClass($class)
199217
return $bool;
200218
}
201219

202-
public function hasAttr($attr, $val)
203-
{
204-
205-
foreach($this->obj as $item)
206-
{
207-
$attrs = $item->getAttribute("$attr");
208-
}
209-
210-
$bool = (preg_match("/".preg_quote($val)."/", $attrs)) ? true : false;
211-
212-
return $bool;
213-
}
214-
215220
public function html($html = null){
216221

217222
if (!isset($html))

0 commit comments

Comments
 (0)