2016-11-27 12 views
0

나는 위키 백과를위한 도구를 만들고 있습니다. file_get_contents를 사용하여 https://de.wikipedia.org/wiki/Spezial:Linkliste/Hans_Jansen_(Arabist) 페이지를 검색하려고합니다. 그런 다음 목록을 찾아서 \ n 탐색하여 모든 목록 항목을 추출합니다.'을 file_get_contents의 출력에서 ​​없애기

이후 목록 항목의 이름을 지정한 기사 텍스트를 검색하고 싶습니다. 이를 위해 나는

file_get_contents(https://de.wikipedia.org/w/index.php?action=raw&title=".urlencode($article)); 

모든 내가 일반 텍스트로 문서 이름을 복사 할 때

https://de.wikipedia.org/w/index.php?action=raw&title=Ka 

의 검색에 이르게 Ka'b 이븐 As'ad라는 기사 다 할 때까지 잘 어울린다 할 수동으로 입력 및 웹 사이트에서 검색 $의 기사를 urlencode의 출력을 비교

$article = "Ka'b ibn As'ad"; 
$page = "https://".$server."/w/index.php?action=raw&title=".urlencode($article); 

의 차이를 보여줍니다 : 잘 어울리는

manually; Ka%27b+ibn+As%27ad 
    website: Ka%26%23039%3Bb%20ibn%20As%26%23039%3Bad 

더욱 인상적인 반드시 htmlspecialchars와 출력을()입니다 비교 :

manually; Ka'b ibn As'ad 
    website: Ka'b ibn As'ad 

어떻게는 그 ' 특수 문자를 제거합니까? 분명히 htmlspecialchars_decode()가 작동하지 않습니다.

답변

0

htmlspecialchars_decode()는 숫자가 아닌 html 엔티티 만 변환합니다. 이 경우 html-entity-decode()을 사용해야합니다!