From f98f9b5c53e65fa6cf4bb16fe967add2c8d4b883 Mon Sep 17 00:00:00 2001 From: Chang Long Xu Date: Wed, 10 Oct 2018 12:04:51 +0800 Subject: [PATCH 1/2] fixed json wrong old blog will no comment --- Sina2WordPressCore.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sina2WordPressCore.py b/Sina2WordPressCore.py index 1354cfe..c0904ea 100644 --- a/Sina2WordPressCore.py +++ b/Sina2WordPressCore.py @@ -94,8 +94,11 @@ def __init__(self, interface, sina_url, wordpress_admin, wordpress_url): msg = '(%d/%d) Analyzing Comment: %s' % (count, total, comment_url, ) interface.progress_update(msg, count, total) - comment_text, comment_id = comment_analyze( - comment_url, comment_id, sina_admin, wordpress_admin, wordpress_url) + try: + comment_text, comment_id = comment_analyze( + comment_url, comment_id, sina_admin, wordpress_admin, wordpress_url) + finally: + break if comment_text: text.append(comment_text) From f9155ee0da18903b994f4c919e900409a1b99b33 Mon Sep 17 00:00:00 2001 From: Chang Long Xu Date: Wed, 10 Oct 2018 12:56:05 +0800 Subject: [PATCH 2/2] fixed wrong process fixed wrong process --- Sina2WordPressCore.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sina2WordPressCore.py b/Sina2WordPressCore.py index c0904ea..dbff346 100644 --- a/Sina2WordPressCore.py +++ b/Sina2WordPressCore.py @@ -97,7 +97,7 @@ def __init__(self, interface, sina_url, wordpress_admin, wordpress_url): try: comment_text, comment_id = comment_analyze( comment_url, comment_id, sina_admin, wordpress_admin, wordpress_url) - finally: + except: break if comment_text: @@ -183,7 +183,10 @@ def post_analyze(url, wordpress_admin): page = urlopen_request(request) #headers['Referer'] = url - post_title = content_clear(post_title_pattern.search(page).group(1)) + try: + post_title = content_clear(post_title_pattern.search(page).group(1)) + except: + return '','' post_time = post_time_pattern.search(page).group(1) post_content = content_clear(post_content_pattern.search(page).group(1))