我正在尝试查看网站fortune.com/best-companies的全部内容。 原始代码中的脚本具有以下标签:
<nav id="bottom-panel-pagination" class="panel-pagination hasNextOnly">
<div data-event="view left" class="prev-page icon-new-left-arrow"></div>
<div data-event="view right" class="next-page icon-new-right-arrow"></div>
</nav>
我想使用BeautifulSoup将类属性"panel-pagination hasNextOnly"更改为"panel-pagination hasNoPagination"。我的Python代码如下:
import urllib2
from bs4 import BeautifulSoup
quote_page = "http://fortune.com/best-companies/"
page = urllib2.urlopen(quote_page)
soup = BeautifulSoup(page, "html.parser")
fullpage = soup.find('nav', attrs = {'class' : 'panel-pagination hasNextOnly'})
print fullpage
我想将attrs = {'class' : 'panel-pagination hasNextOnly'}更改为attrs = {'class' : 'panel-pagination hasNoPagination'},该网站应在此之后重新加载,以便我可以进一步进行爬取。我该怎么做?请帮忙。