Beautiful Soup获取数据绑定元素

huangapple go评论60阅读模式
英文:

Beautiful Soup Get Data Bind Element

问题

<div class="col-xs-12 col-sm-2">
    <span class="small text-muted">法院</span>
</div><div class="col-xs-11 col-xs-offset-1 col-sm-10 col-sm-offset-0">
    <span class="small" data-bind="html: model.Court">韦恩镇</span>
from bs4 import BeautifulSoup

response_soup = BeautifulSoup(response.text, 'html.parser')

court = response_soup.find('span', {'class': 'Model.court'}).text

结果是 NONE
我正在尝试获取韦恩镇
韦恩镇不会始终是结果。
任何帮助将不胜感激。

英文:
<div class="col-xs-12 col-sm-2">
                    <span class="small text-muted">Court</span>
                </div><div class="col-xs-11 col-xs-offset-1 col-sm-10 col-sm-offset-0">
                    <span class="small" data-bind="html: model.Court">Wayne Township</span>



from bs4 import BeautifulSoup

response_soup = BeautifulSoup(response.text, 'html.parser')

court = response_soup.find('span', {'class': 'Model.court'}).text

The result is NONE
I am trying to get Wayne Township
Wayne Township will not always be the result.
Any assistance would be most appreciated.

答案1

得分: 0

我明白了。我必须添加selenium正确的语法是court=browser.find_element(By.XPATH,"//span[@data-bind='html: model.Court']")

英文:

I figured it out. I had to add selenium The correct syntax is court=browser.find_element(By.XPATH,"//span[@data-bind='html: model.Court']")

huangapple
  • 本文由 发表于 2023年2月8日 09:45:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75380640.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定