Commits

zsp042 committed 3b8fb9a

fix

Comments (0)

Files changed (1)

misc/websync/site_douban.py

 if __name__ == '__main__':
     pass
 
-#    img = requests.get('http://oldj.net/images/logo.png')
-#    site_douban_site.post(7401035, '1234', '45678', [
-#        ("1.jpg", img.content)
-#    ])
 
     from model.po import Po
     from model.txt2htm import _link_img, RE_IMG
+    from os.path import basename
+
     po = Po.mc_get(10309416)
     txt = po.txt
 
 
     txt = RE_IMG.sub(replace_img, _link_img(txt))
     txt = txt.replace('**' , ' ').replace('[[', ' ( ').replace(']]', ' ) ')
-    print po.name
-    print txt
-    print replace_img.pic_list
 
-#http://site.douban.com/j/note/add_photo
-#-----------------------------24464570528145
-#Content-Disposition: form-data; name="image_file"; filename="1.png"
+    pic_list = []
+    for i in replace_img.pic_list:
+        img = requests.get("http://%s"%i)
+        pic_list.append(
+            (
+                basename(i),
+                img.content
+            )
+        )
 
+    site_douban_site.post(7401035, po.name , txt, pic_list)
 
 
 
-
-