[英]How to use multiple condition findAll in python3?
ex) In html 例如)在HTML
<tr class='odd'> ~~~~
<tr class='even'> ~~~~
I am studying Crawling using Beautiful soup in python3. 我正在研究使用python3中的Beautiful汤进行抓取。
I want to 'odd' class and 'even' class 我想上“奇”班和“偶”班
So, I wrote that 所以,我写了
url = 'http:// ~~~~'
src_code = requests.get(url)
plain_txt = src_code.text
soup = BeautifulSoup(plain_txt, 'lxml')
trTag = soup.findAll('tr', class_ = 'odd' | 'even')
But, 但,
trTag = soup.findAll('tr', class_ ='odd' | 'even')
in this line, error. 在这一行,错误。
I want to find odd class and even class at one go. 我想一次找到奇怪的班级,甚至找到班级。
Is it impossible? 不可能吗
I have to write trTag = soup.findAll('tr',class_='odd') trTag = soup.findAll('tr',class_='even') 我必须写trTag = soup.findAll('tr',class _ ='odd')trTag = soup.findAll('tr',class _ ='even')
separately? 分别?
I want to learn. 我想学习。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.