Skip to content

Instantly share code, notes, and snippets.

View muzizongheng's full-sized avatar

muzizongheng(李建功) muzizongheng

View GitHub Profile
@muzizongheng
muzizongheng / AccessCSDN.py
Created July 18, 2013 06:04
define main function for python module file.
def main():
login_csdn()
url = new_post("title", "content", "categories", "tag2")
print(url)
if __name__ == "__main__":
main()
@muzizongheng
muzizongheng / AccessCSDN.py
Created July 18, 2013 06:04
read dict string and convert string to dict object
data = r.read().decode('utf-8')
reader = json.JSONDecoder()
responseData = reader.decode(data)
return responseData['data']
@muzizongheng
muzizongheng / AccessCSDN.py
Created July 18, 2013 06:03
create http post by using Request
#build request for login url
#post data
postdata = {
'u':username,
'p':password,
'remember':'1',
't':'log',
'f':urllib.parse.quote(moduleUrl),
}
@muzizongheng
muzizongheng / AccessCSDN.py
Created July 18, 2013 06:01
create http get using cookie
#install cookie
cj = cookiejar.CookieJar();
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj));
urllib.request.install_opener(opener)
#build request for accessed url
homeReq = urllib.request.Request(
url = csdnAccessModuleUrl
)
@muzizongheng
muzizongheng / httpencode.py
Created July 18, 2013 06:00
http encode/decode
import base64
from http import cookiejar
import urllib.request, urllib.parse, urllib.error
url = "http://blog.csdn.net/muzizongheng"
en = urllib.parse.quote(url)
print(en)
de = urllib.parse.unquote(en)
print(de)
@muzizongheng
muzizongheng / AccessCSDN.py
Last active February 29, 2024 15:09
login CSDN by using urllib
#Use this utility to access CSDN blog.
#Author: jiangong li
#Email: Jgli_2008@sina.com
import base64
from http import cookiejar
import urllib.request, urllib.parse, urllib.error
#url for accessing
csdnLoginUrl = r"http://passport.csdn.net/ajax/accounthandler.ashx?"
@muzizongheng
muzizongheng / AccessEN.py
Created July 1, 2013 06:39
convert evernote's tags to blog's categories
#create blog category by tags
tagslist = noteStore.listTagsByNotebook(authToken, notebook.guid)
categories = convertTags2Category(tagslist)
try:
for c in categories:
metaweblog.new_category(c)
except Exception as err:
print("Create category failed: ", err)
finally:
#!/usr/bin/python
import cgi, cgitb
# Uncomment this to view errors
# cgitb.enable()
import urlparse
import urllib
import sys
import oauth2 as oauth
#!/usr/bin/python
""""
Copyright 2008 Ritesh Nadhani. All Rights Reserved.
For license information please check the LICENSE page of the package.
"""
import string
from datetime import datetime
from flask import url_for
from flask.ext.xmlrpc import XMLRPCHandler, Fault
from labs import app, db
from labs.models import User, Post, Tag, Category
# MetaWeblogAPI XML-RPC
handler = XMLRPCHandler('api')
handler.connect(app, '/api')