source: vcard/trunk/vcard.py @ 11

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
2import re, urllib2, base64
3
4def 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       
13fin  = open('vcards-XING.vcf', 'r')
14fout = open('vcards-XING-conv.vcf', 'w')
15try:
16        for line in fin:
17                tmp = line
18                if line.startswith('PHOTO;VALUE=URI:'):
19                        tmp = downloadAndConvert(line)
20                fout.write(tmp)
21               
22finally:
23        fin.close()
24        fout.close()
Note: See TracBrowser for help on using the repository browser.