开发者

What if beautifulsoups call returns null?

pagelinks = myhtml.findAll('a')

for link in pagelinks:
   do_stuff()
开发者_StackOverflow

If pagelinks is null, will this error out?

How can I make pagelinks a collection of 0 items in case it is null?


findAll returns an empty list [] when nothing matches

for link in pagelinks:
    do_stuff()  # never executed when findAll returns []
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜