Created
August 6, 2016 16:03
-
-
Save lengerfulluse/26b28ec701b17f91daec701643fa6190 to your computer and use it in GitHub Desktop.
This file contains 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 | |
from __future__ import print_function | |
import re | |
def url_mapping(): | |
'''Mapping jekyll like http://t.hengwei.me/post/title/ ---> http://t.hengwei.me/post/title.html''' | |
with open("lengerfulluse-old.csv", 'r') as fo, open("lengerfulluse-url-mapping.csv", 'w') as fw: | |
for line in fo: | |
replace_line = re.sub(r'http://t.hengwei.me/post/(.*)/', r'http://t.hengwei.me/post/\1.html', line.rstrip()) | |
print("{}, {}".format(line.rstrip(), replace_line), file=fw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, it's just a workable tools for my own url migration task, need refactor to be more general.