내가이 크롤러가이 크롤러을 개선하지만, 인덱스에만 도메인 루트 전합니다 mydomain.com하지만 /somethingelse.php하지, 내가 웹 사이트 내부 링크를 의미 /otherpage.html ...필요한 도움
을 이 스크립트를 수정하여 루트가 아닌 더 많은 페이지를 색인 할 수있는 방법이 있습니까?
<?php
require_once('./pathtoconfig');
require_once('./functions.php')
set_time_limit(500);
error_reporting(-1);
header('Content-Type: text/plain; charset=utf-8;');
$db = @mysqli_connect($conf['host'], $conf['user'], $conf['pass'], $conf['name']);
mysqli_query($db, 'SET NAMES utf8');
if(!$db) {
echo "Failed to connect to MySQL: (" . mysqli_connect_errno() . ") " . mysqli_connect_error();
}
//Insert links separated by commas.
$url = array('mydomain1.com', 'mydomain2.com');
foreach($url as $k) {
$url = parse_url($k);
if(!isset($url['path'])) {
$selectData = "SELECT * FROM web WHERE url = '$k'";
if(mysqli_fetch_row(mysqli_query($db, $selectData)) == null) {
$content = getUrl($k);
preg_match('#<title>(.*)</title>#i', $content, $title);
preg_match_all('/<img src=.([^"\' ]+)/', $content, $img);
preg_match('/<head>.+<meta name="description" content=.([^"\']+)/is', $content, $description);
preg_match('/<head>.+<meta name="author" content=.([^"\']+)/is', $content, $author);
#preg_match_all('/href=.([^"\' ]+)/i', $content, $anchor);
preg_match('/<body.*?>(.*?)<\/body>/is', $content, $body);
if(!empty($title[1]) AND !empty($description[1]) || !empty($body[1])) {
echo 'Title: '; @print_r($title[1]);
echo "\n";
$body_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$body[0])))); $bodyContent = substr(preg_replace('/\s+/', ' ', $body_trim), 0, 255);
$description_trim = trim(preg_replace("/&#?[a-z0-9]+;/i",'',(strip_tags(@$description[1])))); $descContent = substr(preg_replace('/\s+/', ' ',$description_trim), 0, 255);
$bodyContent = str_replace('\'', '', $bodyContent);
$descContent = str_replace('\'', '', $descContent);
echo 'Description: '; @print_r($descContent);
echo "\n";
echo 'Author: '; @print_r($author[1]);
echo "\n";
echo 'URL: '; @print_r($k); $date = date("d M Y");
echo "\n";
echo "\n---------------------------------------------------------------------------\n";
$insertData = "INSERT INTO `web` (`url` , `title` , `description` , `body` , `author`, `date`) VALUES ('".$k."', '"[email protected]$title[1]."', '"[email protected]$descContent."', '"[email protected]$bodyContent."', '"[email protected]$author[1]."', '".$date."')";
#echo $insertData;
mysqli_query($db, $insertData);
}
}
}
}
?>
희망을 주셔서 감사합니다. 정말 감사합니다.
로드 한 문서 내에서 링크를 찾으려고 했습니까? –
예. .com 뒤에 확장자가 있으면로드되지 않습니다. –
문서 내에서 링크를 찾는 코드는 어디에 있습니까? –