为了账号安全,请及时绑定邮箱和手机立即绑定

BeautifulSoup 剥离空白

BeautifulSoup 剥离空白

慕雪6442864 2021-08-24 19:08:42
我正在研究一个网站上的基本星座分析器。下面是我的代码:import requestsfrom bs4 import BeautifulSoup as bsurl = "https://www.astrospeak.com/horoscope/capricorn"response = requests.request("GET", url)soup = bs(response.text, 'html.parser')locater = soup.select("#sunsignPredictionDiv > div.fullDIV > div.lineHght18 > div")quote = locater[0].previousSibling这给我留下了以下内容<class 'bs4.element.NavigableString'>:"\n                      You are working towards yet another dream and as you pursue this vision there's no doubt in your mind that it will come to fruition. It's written in the stars! \n                      "我正在努力如何stripped_strings在 bs4.element.NavigableString 上使用 BeautifulSoup生成器。我想最终得到的只是字符串You are working towards yet another dream and as you pursue this vision there's no doubt in your mind that it will come to fruition. It's written in the stars!
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 213 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号