NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type.

“C:\Program Files\Python36-32\python.exe” C:/Users/Administrator/PycharmProjects/untitled/getiFanxu.py
[<h1 class=”entry-title”>支付宝扫码领红包</h1>]
Traceback (most recent call last):
File “C:/Users/Administrator/PycharmProjects/untitled/getiFanxu.py”, line 21, in <module>
img = soup.select(‘#post-2266 > div > p:nth-child(1) > a > img’)
File “C:\Program Files\Python36-32\lib\site-packages\bs4\element.py”, line 1532, in select
for candidate in _use_candidate_generator(tag):
File “C:\Program Files\Python36-32\lib\site-packages\bs4\element.py”, line 1493, in recursive_select
for i in tag.select(next_token, recursive_candidate_generator):
File “C:\Program Files\Python36-32\lib\site-packages\bs4\element.py”, line 1451, in select
‘Only the following pseudo-classes are implemented: nth-of-type.’)
NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type.

Process finished with exit code 1

解决办法为:nth-child改为nth-of-type 

Use nth-of-type instead of nth-child

发表评论