title: list out of range 12
body: <p>I want to use BeautifulSoup4 to get the total number pages of the BBS.So I write this code:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  
  
  soup = BeautifulSoup('A lot of HTML here', 'html.parser')
  pagenumber = soup.find_all("div",class_="pagelinks")[0]
  page_toatal_num = pagenumber.find_all("a")[-1].get_text()
  print page_toatal_num
  </code></pre>
  
  <p>The elements of the page is here:
  <a href="https://i.stack.imgur.com/bfVuz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bfVuz.png" alt="enter image description here"></a></p>
  
  <p>At this photo , I want to get "342",and by my way,I got it. But,what confusing is that,it raise the error:"list index out of range".In the cmd.exe, it both print the "342" but also raise the error. why?and how can I solve this problem</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python27\lib\site-packages\scrapy\utils\defer.py", line 102, in iter_
  errback
      yield next(it)
    File "C:\Python27\lib\site-packages\scrapy\spidermiddlewares\offsite.py", line
   29, in process_spider_output
      for x in result:
    File "C:\Python27\lib\site-packages\scrapy\spidermiddlewares\referer.py", line
   22, in &lt;genexpr&gt;
      return (_set_referer(r) for r in result or ())
    File "C:\Python27\lib\site-packages\scrapy\spidermiddlewares\urllength.py", li
  ne 37, in &lt;genexpr&gt;
      return (r for r in result or () if _filter(r))
    File "C:\Python27\lib\site-packages\scrapy\spidermiddlewares\depth.py", line 5
  8, in &lt;genexpr&gt;
      return (r for r in result or () if _filter(r))
    File "C:\python_workspace\deep_web\deep_web\spiders\deepSpider.py", line 73, i
  n parse_item
      page_toatal_num = pagenumber.find_all("a")[-1].get_text()
  IndexError: list index out of range
  </code></pre>