问题:
UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently. The code that caused this warning is on line 10 of the file D:python_work est est.py. To get rid of this warning, pass the additional argument 'features="html.parser"' to the BeautifulSoup constructor. noStarchSoup = bs4.BeautifulSoup(res.text)
解决方法:
noStarchSoup = bs4.BeautifulSoup(res.text,features='html.parser')
《CSS选择器的例子》,select()方法将返回一个Tag对象的列表
传递给select()方法的选择器 | 将匹配... |
soup.select('div') | 所有名为<div>的元素 |
soup.select('#author') | 带有id属性为author的元素 |
soup.select('.notice') | 所有使用CSS class属性名为notice的元素 |
soup.select('div span') | 所有在<div>元素之内的<span>元素 |
soup.select('div >span') | 所有直接在<div>元素之内的<span>元素,中间没有其他元素 |
soup.select('input[name]') | 所有名为<input>,并有一个name属性,其值无所谓的元素 |
soup.select('input[type="button"]') | 所有名为<input>,并有一个type属性,其值为button的元素 |