首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >找不到此HTML的Beautifulsoup find()命令

找不到此HTML的Beautifulsoup find()命令
EN

Stack Overflow用户
提问于 2018-07-27 04:05:45
回答 1查看 221关注 0票数 0

我试图从python和Beautiful soup的页面中抓取一些信息,但我似乎无法将正确的路径写到我需要的地方,html是:

<div class="operator active" data-operator_name="Etisalat" data- 
operator_id="5"><div class="operator_name_etisalat"></div></div>

我正在尝试获得名为"Etisalat“的运算符,我得到了以下结果:

def list_contries():

select = Select(driver.find_element_by_id('international_country'))
select.select_by_visible_text('France')
request = requests.get("https://mobilerecharge.com/buy/mobile_recharge?country=Afghanistan&operator=Etisalat")
content = request.content
soup = BeautifulSoup(content, "html.parser")
# print(soup.prettify())
prov=soup.find("div", {"class": "operator active"})['data-operator_name']
# prov = soup.find("div", {"class": "operator deselected"})
print(prov)
operator = (prov.text.strip())

但这只会返回一个NoneType。所以有些地方不对劲,有人能告诉我我哪里做错了吗?谢谢。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51546730

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档