查看更多

Web开发中的那些事儿

pyquery实现jquery的each方法

#for z in [pq(x).siblings('a') for x in d('span .pl') if pq(x).text() == '编剧']:

scriptwriters = [] 

for scriptwriter in d("span .pl").filter(lambda i: PyQuery(this).text() == '编剧').siblings('a'):#class为pl的span标签,内容为‘编剧’的兄弟a标签

        scriptwriters.append(pq(scriptwriter).text())


注:lambda i: PyQuery(this).text() == '编剧'   此处不是用i,具体可以看https://pythonhosted.org/pyquery/api.html

评论
©Web开发中的那些事儿 | Powered by LOFTER