# 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() == '编剧' 此处用this不是用i
参考:
http://pythonhosted.org/pyquery/api.html