This repository has been archived by the owner on Sep 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpage-one.php
78 lines (69 loc) · 2.76 KB
/
page-one.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Template Name: One 一个
*/
$url = 'http://wufazhuce.com';//one一个url
$data = get_file($url);
//数据接收完成
//准备分析数据
$title = '/(?<=(<p class="titulo">))[^<]*(?=(<\/p>))/';//匹配标题
$num_1 = preg_match_all($title, $data, $match_title);
$imgurl = '/(?<=(<img class="fp-one-imagen" src="))[^<]*(?=(" alt="" \/><\/a> ))/';//匹配图片url
$num_2 = preg_match_all($imgurl, $data, $match_imgurl);
$img_title = '/(?<=( ))[^>]*(?=(&))/';//匹配图片标题
$num_3 = preg_match_all($img_title, $data, $match_imgtitle);
$img_author = '/(?<=(&))[^<]*(?=(<\/div>))/';//匹配图片作者
$num_4 = preg_match_all($img_author, $data, $match_imgauthor);
$word = '/(?<=(<a href="http:\/\/wufazhuce.com\/one\/)\d{4}">)[^>]*(?=(<))/';//匹配文字
$num_5 = preg_match_all($word, $data, $match_word);
//数据分析完成
//准备处理数据
//echo "function onetitle(){document.write(\"" . $match_title[0][0] . "\");}";
//echo "function oneimga(){document.write(\"" . $match_imgtitle[0][0] . '<br>' . $match_imgauthor[0][0] . "\");}";
//echo "function oneword(){document.write(\"" . $match_word[0][1] . "\");}";
//数据处理完成
function get_file($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
//对接成功
?>
<?php get_header(); ?>
<section id="primary" class="content-area">
<main class="full-page">
<div class="full-content">
<div class="akina_one">
<div class="akina_one_image">
<img src="<?php echo get_stylesheet_directory_uri() .'/inc/one/img.php'; ?>" alt="One一个绘图"/>
</div><!--One图片-->
<div class="akina_one_main">
<div class="akina_one_text">
<div class="akina_one_title"><?php echo $match_title[0][0] ?></div>
<div class="akina_one_content"><?php echo $match_word[0][1] ?></div>
</div>
<div class="akina_one_time">
<div class="date"><?php echo date('d');?></div>
<div class="year"><span><?php echo date('M',get_the_time('U'));?></span><?php echo date('Y');?></div>
</div><!--日期-->
</div><!--One一句-->
</div>
<div>
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'inc/content-single', 'page' );
// End of the loop.
endwhile;
?>
</div>
</div>
</main>
</section>
<?php get_footer(); ?>