-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery_sen.php
57 lines (51 loc) · 1.58 KB
/
query_sen.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
// -*- coding: utf-8 -*-
/* query_woori.php
* search book from a library based on Woori eBook platform
* Input:
* type : [title|author]
* keyword: <string>
* url : library address
*/
/*
* search URL: /12_search/search_result.php
* Input: GET method (EUC-KR)
* ct : [Cont_name|Cont_author]
* keyword[] : keyword
* Output: HTML output
* <!--콘텐츠이름검색 결과 화면-->
* ...
* <!-- content_body : End //-->
*/
$srchtype = $_GET['type'];
$keyword = $_GET['keyword'];
$home_url = $_GET['url'];
$alt_type = false;
$type_map = array('title'=>'Cont_name',
'author'=>'Cont_author');
$fields = array(
'ct' => $type_map[$srchtype],
'keyword[]' => mb_convert_encoding($keyword,"EUC-KR","UTF-8")
);
$url = $home_url."/12_search/search_result.php?".http_build_query($fields,"&");
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US)\r\n"
)
);
$context = stream_context_create($opts);
$html = file_get_contents($url, false, $context);
$html = mb_convert_encoding($html, "UTF-8", "EUC-KR");
$pos1 = strpos($html, "<!--콘텐츠이름검색 결과 화면-->");
$pos2 = strpos($html, "<!-- content_body : End //-->");
$html2 = substr($html, $pos1, $pos2-$pos1);
$html2 = str_replace('="/', '="'.$home_url.'/', $html2);
include "parse_sen.php";
$dom = parse_sen($html2);
$node = $dom->documentElement->appendChild( $dom->createElement("search_url") );
$node->appendChild( $dom->createTextNode( $url ) );
header("Content-type: text/xml");
$dom->formatOutput = true;
echo $dom->saveXML();
?>