python使用beautifulsoup爬虫笔记

嵌套抓取子元素

soup = BeautifulSoup(html_doc,'html.parser', from_encoding='utf-8')
tableArea=soup.find('table',class="table table-hover table-striped")
state_trs=tableArea.find_all('tr')
      for tr in state_trs:
          title_node=state_trs.find_all('td')
          print title_node.get_text()

你可能感兴趣的:(python使用beautifulsoup爬虫笔记)