Archive for the ‘软件工具’ Category
在Mac系统下安装Wine
这是篇给那些想在自己的Mac系统下安装使用Wine的用户们的教程。你需要知道如何使用命令行。如果你不会用,先读下其他教程。
目录
Wine是什么?
Wine能运行我想要用的程序吗?
要求
第一章 安装MacPorts
第二章 配置MacPorts
第三章 利用MacPorts安装Wine
第四章 利用Wine安装Windows程序
第五章 利用Wine运行Windows程序
保持Wine版本最新
卸载Wine与MacPorts
测试下SyntaxHighlighter插件
在Writer上尝试了SyntaxHighlighter for Windows Live Writer与Windows Live Writer Source Code plugin for SyntaxHighlighter均告失败,最后用了一款国人做的插件代码插入插件,结果发现还是TMD用自己手打最稳,之后又发生各种格式不对,在经过了一番折腾后:毅然的把SyntaxHighlighter Evolved插件换成SyntaxHighlighter2后解决问题。
把我以前写的人人日志备份工具当例子吧:(查看全篇文章能看到)
【原创】人人(校内)日志导出RSS备份工具
根据http://laoyang.yo2.cn/articles/export-blogs-from-xiaonei.html 改出来的,原来的输出实在不好导入别的blog。
可以直接输出xml,校内日期转成GMT的了,这样导入时时间不会乱套。
用法与原来一样,python 2.5下正常,别的就不知道了。
1.安装python 2.5,在下载的文件目录下cmd运行python renren2rss.py
2.输入用户名、密码,回车
同目录下的renrenblog.xml就是备份文件了,缩进没怎么做,记事本打开别看吐了就行。直接导入z-blog测试正常。
# -*- coding: utf-8 -*-
import sys
import os
import string
import htmllib
import urllib
import urlparse
import formatter
from sys import argv
from urllib import urlretrieve
from urllib import urlencode
import urllib2
import cookielib
import re
import datetime
def write_content(f,content):
f.write('<description><![CDATA['+content+']]></description>\n')
def addtorss(f,name):
file=open(name)
line = file.readlines()
# find the title of the blog entry
f_title = ''
data = '<title>'
j = 0
for eachLine in line:
j=j+1
m = re.search(data,eachLine)
if m is not None:
break
strs = line[j-1]
n_start = strs.find('<title>')+7
n_end = strs.rfind('</title>')
f_title = strs[n_start:n_end]
f.write('\n\n\n<item><title><![CDATA['+ f_title + ']]></title>\n')
i = 0
for eachLine in line:
i = i + 1
m = re.search('id="blogContent"',eachLine)
if m is not None:
break
f_content = line[i+1]
write_content(f,f_content)
# find the time of the blog entry
f_time = ''
data = '"timestamp"'
j = 0
for eachLine in line:
j=j+1
m = re.search(data,eachLine)
if m is not None:
break
strs = line[j-1]
n_start = strs.find('span class="timestamp"')+23
n_end = strs.rfind('<span class="group">')
f_time = strs[n_start:n_end]
gmt_format='%a, %d %b %Y %H:%M:00 GMT+8'
time_format='%Y-%m-%d %H:%S '
time=datetime.datetime.strftime(datetime.datetime.strptime(f_time,time_format),gmt_format)
f.write('<pubDate>'+ time +'</pubDate>\n</item>\n')
def main():
# login to xiaonei
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
opener.addheaders = [
("User-agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"),
("Accept","text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1"),
("Host","www.renren.com"),
("Referer","http://home.renren.com/Home.do"),
('Accept-Language', 'zh-CN,zh;q=0.8'),
('Accept-Charset', 'GBK,utf-8;q=0.7,*;q=0.3'),
('Keep-Alive', '300'),
('Connection', 'keep-alive'),
('Cache-Control', 'max-age=0')
]
UserName=raw_input('your email in renren.com:')
Password=raw_input('your password:')
data = {
'email': UserName,
'password': Password,
'origURL':"http://www.renren.com/Home.do",
'submit': '登录'
}
urldata = urlencode(data)
r = opener.open("http://passport.renren.com/PLogin.do", urldata)
results = r.read()
#personal homepage is saved as the start.html
open('start.html', 'w').write(results)
r = urllib2.urlopen("http://blog.renren.com/MyBlog.do")
results = r.read()
#blog homepage is saved as the user.txt
open('user.txt', 'w').write(results)
# get the whole article number
file = open('user.txt')
line = file.readlines()
file.close()
data = '当前显示1-10篇/共\d*篇'
article_num = 0
#find the article num below
for eachLine in line:
m = re.search(data,eachLine)
if m is not None:
strs = m.group()
num_start = strs.rfind('共')+3
num_end = strs.rfind('篇')
article_num = string.atoi(strs[num_start:num_end],10)
break
print 'you have %d articles in total' %(article_num)
#download the articles
#make save xml file
save_file = open('renrenblog.xml','w')
save_file.write('\n\n<?xml version="1.0" ?>\n<!-- generator="toyjack" -->\n <rss version="2.0">\n<channel>\n<title><![CDATA[RENREN日志]]></title>\n<link></link>\n<description>by toyjack@gmail.com</description>\n')
k = 1
#get the first entry
file = open('user.txt')
line = file.readlines()
file.close()
data = 'http://blog.renren.com/GetEntry.do\?id=\d*&owner=\d*'
for eachLine in line:
#print eachLine
m = re.search(data,eachLine)
if m is not None:
strs = m.group()
break
r = urllib2.urlopen(strs)
results = r.read()
open('temp.txt', 'w').write(results)
print "now downloading the ", k, "th articles"
addtorss(save_file,'temp.txt')
for k in range(2,article_num+1):
file = open('temp.txt')
line = file.readlines()
file.close()
data = 'http://blog.renren.com/GetPreBlog.do\?id=\d*&owner=\d*&time=\d*&op=pre'
for eachLine in line:
m = re.search(data,eachLine)
if m is not None:
strs = m.group()
break
r = urllib2.urlopen(strs)
results = r.read()
open('temp.txt','w').write(results)
print "now downloading the ", k, "th articles"
addtorss(save_file,'temp.txt')
save_file.write('\n\n</channel>\n</rss>\n')
save_file.close()
## file=open('blog.txt')
## line=file.readlines()
## file.close()
## data='src=".*\.\w{3,4}" '
## for eachLine in line:
## m=re.search(data,eachLine)
## if m is not None:
## strs=m.group()
## print strs
os.remove('temp.txt')
os.remove('start.html')
os.remove('user.txt')
if __name__ == '__main__':
main()
参考:http://blog.csdn.net/kernelspirit/archive/2007/11/19/1891984.aspx