Home > Technology > 获取 VeryCD 站点标题

获取 VeryCD 站点标题

前段时间眼红好友们的人人帐号级别都很高, 我就写了一个模拟登录的脚本, 每天定时登录人人并发布一个新的状态, 加快升级. 在考虑状态用语的时候, 突然想到了电驴子 VeryCD 的标题每次都不一样, 而且很多语句都非常励志, 或者积极向上. 于是考虑把它爬下来, 随机选择一个, 作为人人网状态发布. 现在我把读取 VeryCD 网站标题的代码张贴一下. ;-)

PHP 方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * 取得当日 VeryCD 的随机标题
 * 
 * @return array
 */
function getTitlesOfVeryCD() {
	$orgContent = file_get_contents('http://www.verycd.com/statics/title.saying');
	$matchResult = preg_match('/new\s+Array\((.+)\);\s+_VC_/', $orgContent, $matches);
	$results = array();
	if ($matchResult) {
		$results = explode('\', ', $matches[1]);
		foreach ($results as &$v) {
			$v = str_replace('\'', '', $v);
		}
	}	
	unset($orgContent, $matches);
	return $results;
}

Java 方式

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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
/**
 * 读取 VeryCD 的随机标题
 * 
 * @author yinheli
 *
 */
public class TitlesOfVeryCD {
	/**
	 * 取得当日全部的标题
	 * 
	 * @return 当天的标题数组
	 * @throws IOException
	 */
	public static String[] get() throws IOException {
		URL url = new URL("http://www.verycd.com/statics/title.saying");
		BufferedReader br = new BufferedReader(
			new InputStreamReader(
				url.openConnection().getInputStream()
			)
		);
 
		StringBuilder contentSB = new StringBuilder();
		String line = null;
		while ((line = br.readLine()) != null) {
			contentSB.append(line);
		}
		br.close();
 
		String content = contentSB.toString();
 
		Pattern p = Pattern.compile("new\\s+Array\\((.+)\\);\\s+_VC_");
		Matcher m = p.matcher(content);
		String[] results = null;
		if (m.find()) {
			results = m.group(1).split("',\\s?");
			for (int i = 0; i < results.length; i++) {
				results[i] = results[i].replace("'", "");
			}
		}
 
		return results;
	}
}
  1. 托比天空 Jul 16th, 2010 @ 12:37 | #26

    你这个主题 怎么实现
    回复评论者评论邮件发送啊??
    附上我的QQ:287450217
    不过 最好 到gmail邮箱吧
    谢谢
    你这款主题不错,我很喜欢。。
    就是 前面问题 咋解决的?
    求助……
    多谢!

  2. Persona4 Jul 18th, 2010 @ 18:24 | #27

    试试这个,JavaScript的,不过要在verycd的主页用
    javascript:vcTitle = document.title;if(vcTitle == null){var t_titles = document.getElementByTagName(“title”);if(t_titles && t_titles.length >0){vcTitle = t_titles[0];}else{vcTitle = “”;}}alert(vcTitle.substring(8));
    头一次来你blog,是看到茶馆介绍你模版才来的:roll:

  3. ostbp Jul 19th, 2010 @ 17:29 | #28

    站点标题 谢谢分享啦

  4. woleigeca Jul 23rd, 2010 @ 10:13 | #29

    站长看看我的网站woleige.ca用的是GODDAY的空间,用了你的THEME。呵呵,看看速度如何!

  5. 阿七 Jul 23rd, 2010 @ 12:43 | #30

    正需要。这个应该就是那个随机名言吧?

  6. trylife Jul 27th, 2010 @ 19:23 | #31

    有意思 试试

  7. trylife Jul 27th, 2010 @ 19:36 | #32

    关心这个东西“一个模拟登录的脚本, 每天定时登录人人并发布一个新的状态”

  8. lenomon Jul 28th, 2010 @ 16:24 | #33

    喜欢!! 有空搞下!! :lol:

  9. 游轮 Jul 29th, 2010 @ 13:50 | #34

    有意思 试试

  10. 游轮 Jul 29th, 2010 @ 13:55 | #35

    喜欢!! 有意思 试试

  11. teima Aug 4th, 2010 @ 13:22 | #36

    http://abowow.com
    http://abowow.com/wp-login.php
    Anything But Ordinary感谢您使用 PhilNa主题.

    朋友:您好!
    上面这个人到用您的湘ICP备08104465号,在博客中骂人,胡作非为.看快制止吧!

  12. teima Aug 4th, 2010 @ 13:23 | #37

    盗用

  13. roger Aug 10th, 2010 @ 20:24 | #38

    不错的主题
    自己做的吗?

  14. 单阔 Aug 11th, 2010 @ 18:03 | #39

    学习了
    不会java 会点php 不知道 博主有没有好的Java学习教程 线上的

  15. WordPress啦 Aug 11th, 2010 @ 19:20 | #40

    这些内容没有注意过,学习了

  16. PS Aug 22nd, 2010 @ 12:12 | #41

    博主,AdSense的468*60点击率是非常低的,不知道你注意到没。

  17. 雷州 Aug 29th, 2010 @ 05:38 | #42

    非常感谢开发出这么好的主题,我在用了

  18. 成叔叔 Aug 29th, 2010 @ 15:58 | #43

    你还别说,这玩意适合我. ;-)

  19. yxl Sep 5th, 2010 @ 21:44 | #44

    这我朋友你的主题很好,我们都很喜欢
    我现在也想把VeryCD 站点标题也加到我的网站中,所以请问一下应该怎么弄才能加进去。请赐教
    yuxuliang@gmail.com
    QQ:260558245

  20. 老芋头 Sep 5th, 2010 @ 23:18 | #45

    主题不错

Submitting Comment, Give me a second...
Comment pages 1 2

Leave a comment

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackbacks & Pingbacks ( 0 )
  1. No trackbacks yet.