Skip to content

Instantly share code, notes, and snippets.

@lengerfulluse
Created August 6, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lengerfulluse/26b28ec701b17f91daec701643fa6190 to your computer and use it in GitHub Desktop.
Save lengerfulluse/26b28ec701b17f91daec701643fa6190 to your computer and use it in GitHub Desktop.
#!/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)
@lengerfulluse
Copy link
Author

Currently, it's just a workable tools for my own url migration task, need refactor to be more general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment