最近又个小需求来做微信相关的, 又开始找表情了.如图这样
每次需要的时候都要去网上找表情代码,太麻烦了. 所以就写了个个很简单的python爬虫抓了一些表情数据, 顺便熟悉一下python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from pyquery import PyQuery as pq import demjson urls = 'http://www.luxuqing.com/emoji/index.html' dom = pq(url=urls, encoding='UTF-8') itemList = dom.find('table tbody tr') emoji = [] for index in range(0, len(itemList)): if index <= 1000: domData = itemList.eq(index) tdDom = domData.find('td') emojiArr = [] for item in range(0, len(tdDom)): emojiArr.append(tdDom.eq(item).html()) emoji.append(emojiArr) jsonStr = demjson.encode(emoji) open('emoji.json', 'a+').write(jsonStr) |
代码就简单的17行,爬到了这个页面上所有的表情数据( if index <= 1000: 是调试用的, 可忽略)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[ "<span class=\"emoji emoji2614\"/>", "umbrella with rain drops", "U+2614", "U+E640", "U+E48C", "U+E04B", "U+FE002", "☔" ], [ "<span class=\"emoji emoji26C4\"/>", "snowman without snow", "U+26C4", "U+E641", "U+E485", "U+E048", "U+FE003", "⛄" ], ..... |
新做了一个emoji 表情大全, 可以直接复制表情来使用