from bs4 import BeautifulSoup html='''<div class="search ent-search" id='ent_search' data-sudaclick="cnav_search_p"> <form action="http://search.sina.com.cn/" name="cheadSearchForm" id="all_search" method="get" target="_blank" style="position: relative;"> <select name="c" id="search_type" style="visibility: hidden;"> <option value="news">新闻</option> <option value="img">图片</option> <option value="blog">博客</option> <option value="video">视频</option> </select> <input type="hidden" name="ie" value="utf-8"> <div class="search_div"> <input type="text" id="search_input" name="q" value="请输入关键词" onfocus="if(this.value == '请输入关键词') this.value = ''" onblur="if(this.value =='') this.value = '请输入关键词'" autocomplete="off"><input type="submit" id="search_submit" value=""> </div> </form> </div>''' soup = BeautifulSoup(html,'html.parser') print soup.select
我们可以利用 soup.form提取 form标签,
因为select是一个module,
直接 print soup.select会报错
但是现在我要提取上面的select标签,要如何处理?
产品经理不是经理
相关分类