WeChatBot


In [2]:
import menpo.io as mio
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
from menpofit.aam import HolisticAAM, PatchAAM
from menpowidgets import visualize_images, visualize_fitting_result
from menpo.feature import igo, hog, no_op, dsift, double_igo as digo
from menpo.transform import UniformScale, Translation, Rotation, Translation
from menpodetect import load_dlib_frontal_face_detector
import pylab as pl
from menpo.shape import PointCloud, TriMesh
from menpo.transform import AlignmentSimilarity

%matplotlib inline

CalDAV Test


In [3]:
from datetime import datetime
import caldav
from caldav.elements import dav, cdav

# Caldav url
url = "https://mr.yuxiang.zhou@googlemail.com:1330871pP@hostname/caldav.php/"

vcal = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VEVENT
UID:1234567890
DTSTAMP:20100510T182145Z
DTSTART:20100512T170000Z
DTEND:20100512T180000Z
SUMMARY:This is an event
END:VEVENT
END:VCALENDAR
"""


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-59bff1b7fc00> in <module>()
      1 from datetime import datetime
----> 2 import caldav
      3 from caldav.elements import dav, cdav
      4 
      5 # Caldav url

ImportError: No module named caldav

In [ ]:
client = caldav.DAVClient(url)
principal = client.principal()
calendars = principal.calendars()
if len(calendars) > 0:
    calendar = calendars[0]
    print "Using calendar", calendar

    print "Renaming"
    calendar.set_properties([dav.DisplayName("Test calendar"),])
    print calendar.get_properties([dav.DisplayName(),])

    event = calendar.add_event(vcal)
    print "Event", event, "created"

    print "Looking for events in 2010-05"
    results = calendar.date_search(
        datetime(2010, 5, 1), datetime(2010, 6, 1))

    for event in results:
        print "Found", event

Auto Reply Test


In [1]:
import requests, json
def tulingReply(text):
    key = '56bbd71ded658acbd04169a21b605114'
    r = requests.get(
        'http://www.tuling123.com/openapi/api?key={}&info={}&userid='.format(
            key,text
        )
    )
    return r.text

print tulingReply('想吃泡面')


{"code":308000,"text":"亲,已帮您找到菜谱信息","list":[{"name":"深夜泡面","icon":"http://s1.cdn.xiachufang.com/040c02667d7811e5843a35065ad47291.jpg@2o_50sh_1pr_1l_280w_216h_1c_1e_90q_1wh.jpg","info":"随便什么泡面一包、海苔肉松 | 葱、芹菜、意大利香草碎","detailurl":"http://m.xiachufang.com/recipe/1050089/"},{"name":"满足食欲的深夜秘密 森系浓香泡面","icon":"http://s2.cdn.xiachufang.com/dad9b2827ed311e594fd8f6e759c3dcf.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"任意方便面、芝士片、鸡蛋、小黄瓜","detailurl":"http://m.xiachufang.com/recipe/100516787/"},{"name":"健康煮泡面","icon":"http://s2.cdn.xiachufang.com/8b722d617dd111e5b7d3bfdee7a1944d.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"火腿肠、蔬菜 | 任何牌子方便面一包、鸡蛋、葱花","detailurl":"http://m.xiachufang.com/recipe/100100421/"},{"name":"韩国芝士泡面","icon":"http://s2.cdn.xiachufang.com/474e0eba7d8611e58e2bcf3462356cf8.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"泡面、芝士片 | 韩国泡菜、火腿肠、芝麻酱、盐、白糖、番茄酱、酱油","detailurl":"http://m.xiachufang.com/recipe/1060423/"},{"name":"韩国泡面","icon":"http://s2.cdn.xiachufang.com/d0bc48997d5d11e5b55e0b0f7ff3c06f.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"泡面 | 丸子、青椒","detailurl":"http://m.xiachufang.com/recipe/1016817/"},{"name":"奶粉泡面","icon":"http://s2.cdn.xiachufang.com/da4484177d8c11e5b3db7762dff629af.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"泡面(各种口味都行) | 奶粉(我的是雀巢全脂奶粉)","detailurl":"http://m.xiachufang.com/recipe/1068148/"},{"name":"世界上第三好吃的泡面^_^","icon":"http://s2.cdn.xiachufang.com/1a12ceae7ec811e5ba6db82a72e00100.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"新加坡叻沙泡面、煮熟的鸡蛋、虾、豆皮","detailurl":"http://m.xiachufang.com/recipe/100502796/"},{"name":"香喷喷芝士泡面~","icon":"http://s2.cdn.xiachufang.com/f477237c7e7011e588f7b82a72e00100.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"芝士 | 辛拉面、鸡蛋","detailurl":"http://m.xiachufang.com/recipe/100392227/"},{"name":"泡面","icon":"http://s2.cdn.xiachufang.com/b9b6a5b37ddc11e594d9bd72949ee93a.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"泡面 | 各种丸子(牛肉、火腿等)、小虾、海带、小白菜、葱、油、盐、鸡精","detailurl":"http://m.xiachufang.com/recipe/100118086/"},{"name":"蛋黄酱泡面","icon":"http://s2.cdn.xiachufang.com/afd70be17e1111e5b0f073481ce53b28.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"杯面(泡面)、蛋黄酱(美乃滋) | 开水","detailurl":"http://m.xiachufang.com/recipe/100261113/"},{"name":"简单美味炒泡面","icon":"http://s2.cdn.xiachufang.com/7a101ec77dbd11e5bac089c29166ac25.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"泡面 | 小青菜、蘑菇、香肠","detailurl":"http://m.xiachufang.com/recipe/100039234/"},{"name":"火腿泡面","icon":"http://s2.cdn.xiachufang.com/d2a6b7d17d9011e59c760ba4ce5257fc.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"香辣泡面、鸡蛋 | 火腿肠、色拉油","detailurl":"http://m.xiachufang.com/recipe/1071782/"},{"name":"辣白菜年糕泡面","icon":"http://s2.cdn.xiachufang.com/c4bf40fa7d4011e5ba2e739a20711506.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"手指年糕、辣白菜泡面 | 韩式辣白菜、年糕辣酱、水、红尖椒、葱","detailurl":"http://m.xiachufang.com/recipe/259763/"},{"name":"韩国版煮泡面","icon":"http://s2.cdn.xiachufang.com/f09ff87c7ec611e5a5cbb82a72e00100.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"泡面、火腿肠、鸡蛋、小白菜、牛肉丸、韩国辣酱、葱、蒜","detailurl":"http://m.xiachufang.com/recipe/100501413/"},{"name":"西红柿泡面","icon":"http://s2.cdn.xiachufang.com/b2d10d237d8311e5ba0bedf4f433e1a9.jpg?imageView2/1/w/280/h/216/interlace/1/q/90/format/jpg/.jpg","info":"西红柿、泡面 | 青椒","detailurl":"http://m.xiachufang.com/recipe/1056168/"}]}

In [ ]: