【发布时间】:2018-06-15 15:27:03
【问题描述】:
我有以下代码:
__PARENT_TAG = "article"
def _navigate_to_xxx(self):
"""acquire html from xxx and beautify the raw html"""
html = requests.get(xxx.__BASE_URL + xxx.__EXTENDED_URL)
self.beautified_html = BeautifulSoup(html.content, "html.parser")
def _extract(self):
"""helper function that extracts elements from beautified_html and returns it"""
element_list = None
element_list = self.beautified_html.findAll(self.__PARENT_TAG)
logging.debug("The number of __PARENT_TAG is: {0}".format(len(element_list)))
return element_list
问题出在同一个网页上,我从调试行得到的结果有时是 18,有时是 20(我预计是 20)。
有人知道为什么会这样吗?
【问题讨论】:
标签: python beautifulsoup request