This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
login_csdn() | |
url = new_post("title", "content", "categories", "tag2") | |
print(url) | |
if __name__ == "__main__": | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = r.read().decode('utf-8') | |
reader = json.JSONDecoder() | |
responseData = reader.decode(data) | |
return responseData['data'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#build request for login url | |
#post data | |
postdata = { | |
'u':username, | |
'p':password, | |
'remember':'1', | |
't':'log', | |
'f':urllib.parse.quote(moduleUrl), | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Use this utility to access CSDN blog. | |
#Author: jiangong li | |
#Email: [email protected] | |
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?" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import cgi, cgitb | |
# Uncomment this to view errors | |
# cgitb.enable() | |
import urlparse | |
import urllib | |
import sys | |
import oauth2 as oauth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
"""" | |
Copyright 2008 Ritesh Nadhani. All Rights Reserved. | |
For license information please check the LICENSE page of the package. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |