나는 PHP로 신입 회원입니다. 내가 뭘 하려는지는 페이지 매김의 링크를 가져 오는 것입니다. 페이지에 페이지 매김이 있으며 페이지를 선택할 때 경로가 변경됩니다. http://ahadith.co.uk/sahihmuslim.php
인 메인 페이지에 머물러서 페이지의 URL을 가져 오는 방법은 무엇입니까?페이지 매김 링크 가져 오기
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ahadith.co.uk/sahihmuslim.php");
//fetches data from the site mentioned above
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$pattern = "/href=[']([^'][a-zA-Z]+.[a-zA-Z]+.[cid]+=[0-9]+)[']?/";
//this regex brings the links from the above url
preg_match_all($pattern, $output, $matches, PREG_PATTERN_ORDER);
foreach ($matches[1] as $data) {
$homepage = file_get_contents('http://ahadith.co.uk/'.$data);
//all the links data which was caught above using regex has been stored in $homepage
$pattern_chapter= "/(?<=\<h2\>)(\s*.*\s*)(?=\<\/h2\>)/";
//Here I have fetched the chapters from the data stored in $homepage
preg_match_all($pattern_chapter, $homepage, $matches_chapter, PREG_PATTERN_ORDER);
foreach ($matches_chapter[1] as $chapters) {
print_r($chapters);
}
?>
지금 내가 $homepage
에 저장된 데이터의 페이지 매김의 링크를 얻을 수 있습니다. 이 경우 페이지 매김에는 44 페이지가 있고 나는 44 페이지 전부의 연결을 얻고 싶다. 이것은 페이지 매김에있는 링크들과 일치하는 정규 표현식입니다. http:\/\/([a-zA-Z]+.[a-zA-Z]+.[a-zA-Z]+.[a-zA-Z]+.[a-zA-Z]+.[cid]+=[0-9]&[a-zA-Z]+=[0-9]&[a-zA-Z]+=[0-9]+)
나는 이것에 대한 많은 장소를 수색했지만 이것과 관련된 것을 찾을 수 없습니다. 제발 아무도 이걸 도와 줄 수 없어요.
내가 모든 것을 다시 시작해야합니다, 내가 매김에서 링크를 얻기 위해 여기에 사용할 수있는 다른 방법이 있습니까? –