<p>你不需要硒。css样式指令中包含了应用给伪<a href="https://www.w3schools.com/cssref/sel_before.asp" rel="nofollow noreferrer">before</a>元素值的内容的说明:</p>
<p><a href="https://i.stack.imgur.com/PUiRS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PUiRS.png" alt="enter image description here"/></a></p>
<p>在这里,<code>.icon-</code>之后的2/3个字母字符串,例如<code>acb</code>映射到容纳<code>before</code>内容的<code>span</code>元素。<code>\9d0</code>后面的值是实际显示值的+1。您可以从这些值对中创建一个字典(进行调整),以便从<code>span</code>类值中解码每个<code>before</code>处的数字。在</p>
<p>2/3字母字符串如何映射到内容的示例:</p>
<p><a href="https://i.stack.imgur.com/riDTb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/riDTb.png" alt="enter image description here"/></a></p>
<p>我的方法可能有点冗长,因为我对Python不太熟悉,但逻辑应该很清楚。在</p>
<pre><code>import requests
import re
from bs4 import BeautifulSoup
url = 'https://www.justdial.com/Bangalore/Spardha-Mithra-IAS-KAS-Coaching-Centre-Opposite-Maruthi-Medicals-Vijayanagar/080PXX80-XX80-140120184741-R6P8_BZDET?xid=QmFuZ2Fsb3JlIEJhbmsgRXhhbSBUdXRvcmlhbHM='
res = requests.get(url, headers = {'User-Agent': 'Mozilla/5.0'})
soup = BeautifulSoup(res.content, 'lxml')
cipherKey = str(soup.select('style[type="text/css"]')[1])
keys = re.findall('-(\w+):before', cipherKey, flags=0)
values = [int(item)-1 for item in re.findall('9d0(\d+)', cipherKey, flags=0)]
cipherDict = dict(zip(keys,values))
cipherDict[list(cipherDict.keys())[list(cipherDict.values()).index(10)]] = '+'
decodeElements = [item['class'][1].replace('icon-','') for item in soup.select('.telCntct span[class*="icon"]')]
telephoneNumber = ''.join([str(cipherDict.get(i)) for i in decodeElements])
print(telephoneNumber)
</code></pre>