Posts

Showing posts from January 24, 2019

BeautifulSoup stripping whitespace

Image
0 I am working on a basic horoscope parser from a website. Below is my code: import requests from bs4 import BeautifulSoup as bs url = "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 This leaves me with the following <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 " I am struggling how I can use the BeautifulSoup stripped_str