response.doc('.link_nei>ul>li>a').items()
上面的语句是用来获取所有符合条件的 <a>,我想获得倒数第二个 <a> 应该怎么获得? 教程上都是通过正则表达式去筛选,不过这种方法好 low 而且不实用
PHPz2017-04-18 10:33:15
response.doc('.link_nei>ul>li>a').eq(-2).items()
Refer to the pyquery documentation https://pythonhosted.org/pyqu...
PHP中文网2017-04-18 10:33:15
I see you are using a CSS selector, just add :nth-last-child(2) after a.
CSS selector tutorial: http://www.w3school.com.cn/cs...