페이지

2012년 1월 26일 목요일

DC인사이드 미드갤에서 한글자막 검색하기

찾아다니기 귀찮아서...

데모보기 »


<html>
<head>
<title>미드 한글자막</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<link rel="stylesheet" href="../jquery.mobile.css" />
<link rel="stylesheet" href="../jquery.mobile.f.css" />
<style type="text/css">
.content.pc { float: left; width: 30%; margin-right: 15px }
.ui-li-desc { font-size: 8pt; font-weight: normal }
.ui-content .ui-listview-inset { margin-top: 0px }
</style>
<script src="../jquery.js"></script>
<script src="../jquery.mobile.js"></script>
<script type="text/javascript">
var ids = [[ "csi", "CSI" ], [ "house", "하우스" ], [ "f_drama", "기미갤" ] ];
var url = "smi.php?c=0&amp;id={id}&amp;p={page}&amp;k=한글자막";
function getURL(id, page, u) {
return url.replace("{id}", id).replace("{page}", page)+(u ? u : "");
}
function genList(ul, data) {
ul.find(":last-child").remove();
$("#list_table tr[onmouseover]:lt(10)", data).each(function () {
var a = $("td:eq(2) a:first", this);
a.find("span").remove();
a.css({ "padding-top": "5px", "padding-bottom": "5px" });
a.attr("href", "http://gall.dcinside.com" + a.attr("href"));
a.html("<h3 class=\"ui-li-heading\">" + a.text().replace(/\[.*\]/g, "") + "</h3>");
a.append("<p class=\"ui-li-desc\">" + $("td:eq(3)", this).text() + " | " + $("td:eq(4)", this).find("span").attr("title") + "</p>");
ul.append($("<li>").append(a).append("<span class=\"ui-li-count\">" + $("td:eq(2) a:last", this).text().replace(/\[|\]/g,"") + "</span>"));
});
ul.listview("refresh");
}
function getList(id, page, u) {
$.ajax({
url: getURL(id, page, u),
type: "GET",
index: id,
success: function (data) {
genList($("#listview_" + this.index), data);
}
});
}
$(document).ready(function () {
for (i = 0; i < ids.length; i++) {
$("#content").append("<div class=\"content\"><ul id=\"listview_" + ids[i][0] + "\" data-role=\"listview\" data-inset=\"true\" data-theme=\"c\" data-dividertheme=\"f\"><li data-role=\"list-divider\">" + ids[i][1] + "</li><li>Loading...</li></ul></div>");
getList(ids[i][0], 1);
}
$(".content").trigger("create");
$(".content ul").listview("refresh");
if (navigator.userAgent.search(/mobile/i) < 0) {
$(".content").each(function () { $(this).addClass("pc") });
}
});
</script>
</head>
<body class="ui-mobile-viewport">
<div data-role="page">
<div data-role="header" data-theme="b">
<h1>DCINSIDE 미드 한글자막 </h1>
<a href="/" data-icon="home" data-iconpos="notext" rel="external" class="ui-btn-left jqm-home">Home</a>
</div><!-- /header -->
<div id="content" data-role="content">
</div>
</div>
</body>
</html>
view raw smi.html hosted with ❤ by GitHub
<?
ini_set('default_charset', 'utf-8');
if (empty($_GET['id'])) $_GET['id'] = 'csi';
if (empty($_GET['p'])) $_GET['p'] = 1;
if (empty($_GET['k'])) $_GET['k'] = '한글자막';//'%ED%95%9C%EA%B8%80%EC%9E%90%EB%A7%89';
if ($_GET['c'] &amp;&amp; is_file('temp/smi')) {
echo file_get_contents('temp/smi');
exit;
}
$params = array(
'id' =&gt; $_GET['id'],
'page' =&gt; $_GET['p'],
'keyword' =&gt; $_GET['k'],
'k_type' =&gt; '0100'
);
if (!empty($uri[6])) $params['search_pos'] = $uri[6];
$url = 'http://gall.dcinside.com/list.php';
$headers = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset: utf-8;q=0.7,*;q=0.3',
'Accept-Encoding: deflate,sdch',
'Accept-Language: ko;q=0.8,en-US;q=0.6,en;q=0.4',
'Cache-Control: max-age=0',
'Connection: keep-alive',
'Host: gall.dcinside.com',
'Referer: http://gall.dcinside.com/list.php?id='.$_GET['id'],
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.23 (KHTML, like Gecko) Chrome/11.0.686.1 Safari/534.23'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
exit;
}
curl_close($ch);
file_put_contents('temp/smi', $result);
chmod('temp/smi', 0666);
echo $result;
?>
view raw smi.php hosted with ❤ by GitHub

댓글 없음:

댓글 쓰기