BeautifulSoup returning none when element definitely exists

后端 未结 4 1090
野性不改
野性不改 2021-01-17 00:58

I\'m new to web scraping and have been using BeautifulSoup to scrape daily mortgage rates. However, a lot of the servicer sites that I am trying to scrape return \'none\' or

4条回答
  •  隐瞒了意图╮
    2021-01-17 01:29

    If you check the page source (for example via view-source: in Chrome or Firefox, or by writing your html string to a file) you'll see that the element you are looking for is not there. In fact, the rates are loaded dynamically:

    
      
        
      
    
    

    You can follow the script URL and you'll see that the response is something like the following:

    document.write('
    2.75%
    ')

    This response is probably regular enough to be able to use regexes on it.

提交回复
热议问题