function handlelink($link) { if (!$link) { return ''; } $link = fillurl($link, $this->reflink); $link = $this->remotefile($link); return $link; }
/** * 从字符串中找出图片多组下载地址,并下载 * @param $str * @param string $baseurl */ function get_more_image($str, $baseurl = '') { preg_match_all('/src=[\'"]?([^\'" ]*)[\'"]?/i', $str, $match_out); if (!empty($match_out[1])) { $match_out[1] = array_unique($match_out[1]); $attachment = load_class('attachment', 'attachment'); $attachment->set_water_mark(false); $newimg = array(); foreach ($match_out[1] as $_m) { $img = fillurl($_m, $baseurl); $newimg[]['url'] = $attachment->get_remote_file($img); } return $newimg; } }
function wz_paseurl($linkurl, $config) { $html = get_curl($linkurl, '', $config['cookie']); $html = str_replace(array("\r", "\n"), '', $html); $html = str_replace(array("</a>", "</A>"), "</a>\n", $html); preg_match_all('/<a([^>]*)>([^\\/a>].*)<\\/a>/i', $html, $out); $out[1] = array_unique($out[1]); $out[2] = array_unique($out[2]); $data = array(); foreach ($out[1] as $k => $v) { if (preg_match('/href=[\'"]?([^\'" ]*)[\'"]?/i', $v, $match_out)) { if ($config['url_include']) { if (strpos($match_out[1], $config['url_include']) === false) { continue; } } if ($config['url_uninclude']) { if (strpos($match_out[1], $config['url_uninclude']) !== false) { continue; } } $url2 = $match_out[1]; $url2 = fillurl($url2, $linkurl, $config); preg_match('/title=[\'"]?([^\'" ]*)[\'"]?/i', $v, $match_out2); $title = strip_tags($match_out2[1]); if ($title == '') { continue; } $data[$k]['url'] = $url2; $data[$k]['title'] = $title; } else { continue; } } return $data; }
function searchlinks($html, $reflink) { $links = array(); $aregions = array(); $regex = "/<a(.+?)href[ ]*=[ |'|\"]*(.+?)[ |'|\"]+/is"; if (preg_match_all($regex, $html, $matches)) { $aregions = array_unique($matches[2]); foreach ($aregions as $aregion) { $aregion = fillurl($aregion, $reflink); $links[] = $aregion; } } return $links; }