Python beautifulsoup

 

 

beautifulsoup通过id获取指定元素内容

bs.find('th', id='DetailTilte')

 

通过class 查找

soup.find_all('span', class_='item_hot_topic_title')

soup.find(class_ ='primaryconsumers')

 

数据处理(将br/换成换行符)

  •   s = str(all_pre) #转换成字符串
  •   s_replace = s.replace('<br/>',"\n") #用换行符替换'<br/>'



 

posted @ 2021-12-05 20:46  emanlee  阅读(48)  评论(0编辑  收藏  举报