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
#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
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
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
#read config | |
input_text = open('config', "r", encoding='utf-8-sig').read() | |
input_json = "{%(input_text)s}" % vars() | |
reader = json.JSONDecoder() | |
config = reader.decode(input_json) |
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
self.isCreateTags = config["isCreateTags"] == str(True) | |
self.syncNotebook = config["syncNotebook"] | |
self.isUsingCSDNBlog = config["isUsingCSDNBlog"] == str(True) |
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
pingServiceUrls = open("pingcfg", "r", encoding='utf-8-sig') | |
pingServiceUrls.seek(0) | |
self.pingServiceUrls = pingServiceUrls.readlines() | |
print(self.pingServiceUrls) |
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
#ping search engine's ping service | |
# http://ping.baidu.com/ping/RPC2 | |
# http://rpc.pingomatic.com/ | |
# http://api.moreover.com/ping | |
# http://api.my.yahoo.com/rss/ping | |
# http://blogsearch.google.com/ping/RPC2 | |
# http://ping.bitacoras.com | |
# http://ping.feedburner.com | |
# http://ping.syndic8.com/xmlrpc.php | |
# http://rpc.blogrolling.com/pinger/ |
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
# List all of the notebooks in the user's account | |
notebooks = noteStore.listNotebooks(authToken) | |
print("Found ", len(notebooks), " notebooks:") | |
#calculate processed blog count currently | |
processedBlogCount = 0 | |
for notebook in notebooks: | |
print(" * ", notebook.name) |
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
#calculate hashcode for media | |
md5 = hashlib.md5() | |
md5.update(attachment.data.body) | |
hashcode = md5.hexdigest() | |
print("hast code: ", hashcode) |