取列表下标【2】的地址数据,按此逻辑取出来的是“\xa0”,即空。请问如何修改代码在取列表下标【2】情况下,得到对应的地址?
[Python] 纯文本查看 复制代码 import chardet
import requests
from bs4 import BeautifulSoup
response = requests.get("https://itemcdn.tmall.com/desc/icoss1752193898fe9ed123908bf24e?var=desc")
encodingInfo = chardet.detect(response.content)
r_response = response.content.decode(encodingInfo['encoding'], 'ignore')
a = response.text.strip('var desc=')
soup = BeautifulSoup(a, features="lxml")
lst = []
for l in soup.find_all('span'):
lst.append(l.text)
print(lst)
|