Python Webscraping:在BeautifulSoup中使用findAll的问题
我试图从这个网站上获取所有的语言 我的代码行只提供了我想要的部分内容Python Webscraping:在BeautifulSoup中使用findAll的问题,python,beautifulsoup,findall,Python,Beautifulsoup,Findall,我试图从这个网站上获取所有的语言 我的代码行只提供了我想要的部分内容 soup.findAll("div",{"class":"block-wrapper block"}) 输出:“[英语:口语,书面]” 基于标签,我也尝试过 soup.findAll("ul",{"class":"has-no-list-styles"}) 输出:“人身伤害产品责任老年人法消费者法DUI&D就业法”我认为这应该可以做到: from bs4 import BeautifulSoup as bs url = '
soup.findAll("div",{"class":"block-wrapper block"})
输出:“[英语:口语,书面]”
基于标签,我也尝试过
soup.findAll("ul",{"class":"has-no-list-styles"})
输出:“人身伤害产品责任老年人法消费者法DUI&D就业法”我认为这应该可以做到:
from bs4 import BeautifulSoup as bs
url = 'https://lawyers.justia.com/lawyer/ali-shahrestani-esq-198352'
data = requests.get(url)
soup = bs(data.text,'lxml')
target = soup.find_all("div",{"class":"heading-3 block-title iconed-heading font-w-bold"})
for t in target:
if t.find('span', class_="jicon -large jicon-languages"):
langs = t.find_next_sibling()
for lang in langs.find_all('li'):
print(lang.text)
输出:
English: Spoken, Written
French: Spoken, Written
Italian: Spoken, Written
Persian: Spoken
Spanish: Spoken, Written