擅长:python、mysql、java
<pre><code>import requests
import bs4
import lxml
result=requests.get("https://www.1mg.com/drugs-all-medicines")
soup = bs4.BeautifulSoup(result.text,"lxml")
scrape=soup.find_all('div', attrs={'class': 'style__font-bold___1k9Dl style__font-14px___YZZrf style__flex-row___2AKyf style__space-between___2mbvn style__padding-bottom-5px___2NrDR'})
bar = soup.find_all('div')[1].text
print(bar)
</code></pre>
<p>输出:<code>Augmentin 625 Duo Tablet</code></p>
<p>这段代码正是您所需要的</p>
<p><code>soup.find_all</code>返回一个列表,您需要在列表中找到该项,然后获取该项的<code>.text</code>属性。在您的例子中,该项是第二项,因此使用第一个索引</p>