Improved profile probing for pump.io
This commit is contained in:
parent
219182d41e
commit
7df60ae634
1 changed files with 25 additions and 9 deletions
|
@ -1332,14 +1332,33 @@ class Probe
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
$data["name"] = $xpath->query("//span[contains(@class, 'p-name')]")->item(0)->nodeValue;
|
||||||
|
|
||||||
|
if ($data["name"] == '') {
|
||||||
// This is ugly - but pump.io doesn't seem to know a better way for it
|
// This is ugly - but pump.io doesn't seem to know a better way for it
|
||||||
$data["name"] = trim($xpath->query("//h1[@class='media-header']")->item(0)->nodeValue);
|
$data["name"] = trim($xpath->query("//h1[@class='media-header']")->item(0)->nodeValue);
|
||||||
$pos = strpos($data["name"], chr(10));
|
$pos = strpos($data["name"], chr(10));
|
||||||
if ($pos) {
|
if ($pos) {
|
||||||
$data["name"] = trim(substr($data["name"], 0, $pos));
|
$data["name"] = trim(substr($data["name"], 0, $pos));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data["location"] = $xpath->query("//p[contains(@class, 'p-locality')]")->item(0)->nodeValue;
|
||||||
|
|
||||||
|
if ($data["location"] == '') {
|
||||||
|
$data["location"] = $xpath->query("//p[contains(@class, 'location')]")->item(0)->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data["about"] = $xpath->query("//p[contains(@class, 'p-note')]")->item(0)->nodeValue;
|
||||||
|
|
||||||
|
if ($data["about"] == '') {
|
||||||
|
$data["about"] = $xpath->query("//p[contains(@class, 'summary')]")->item(0)->nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$avatar = $xpath->query("//img[contains(@class, 'u-photo')]")->item(0);
|
||||||
|
if (!$avatar) {
|
||||||
$avatar = $xpath->query("//img[@class='img-rounded media-object']")->item(0);
|
$avatar = $xpath->query("//img[@class='img-rounded media-object']")->item(0);
|
||||||
|
}
|
||||||
if ($avatar) {
|
if ($avatar) {
|
||||||
foreach ($avatar->attributes as $attribute) {
|
foreach ($avatar->attributes as $attribute) {
|
||||||
if ($attribute->name == "src") {
|
if ($attribute->name == "src") {
|
||||||
|
@ -1348,9 +1367,6 @@ class Probe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data["location"] = $xpath->query("//p[@class='location']")->item(0)->nodeValue;
|
|
||||||
$data["about"] = $xpath->query("//p[@class='summary']")->item(0)->nodeValue;
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue