| Revision 11,
569 bytes
checked in by christian, 3 years ago
(diff) |
|
xing changed its vcard format, I'll follow.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id Author LastChangedDate LastChangedBy
-
Property svn:mime-type set to
text/html
|
| Line | |
|---|
| 1 | #!/usr/bin/env python |
|---|
| 2 | import re, urllib2, base64 |
|---|
| 3 | |
|---|
| 4 | def downloadAndConvert(l): |
|---|
| 5 | url = l[16:] |
|---|
| 6 | print "Fetching " + url |
|---|
| 7 | req = urllib2.Request(url) |
|---|
| 8 | req.add_header('Cache-control', 'no-cache') |
|---|
| 9 | content = urllib2.urlopen(req).read() |
|---|
| 10 | enc = base64.encodestring(content).replace("\n", " ") |
|---|
| 11 | return "PHOTO;BASE64:" + enc + "\n" |
|---|
| 12 | |
|---|
| 13 | fin = open('vcards-XING.vcf', 'r') |
|---|
| 14 | fout = open('vcards-XING-conv.vcf', 'w') |
|---|
| 15 | try: |
|---|
| 16 | for line in fin: |
|---|
| 17 | tmp = line |
|---|
| 18 | if line.startswith('PHOTO;VALUE=URI:'): |
|---|
| 19 | tmp = downloadAndConvert(line) |
|---|
| 20 | fout.write(tmp) |
|---|
| 21 | |
|---|
| 22 | finally: |
|---|
| 23 | fin.close() |
|---|
| 24 | fout.close() |
|---|
Note: See
TracBrowser
for help on using the repository browser.