#python-2.7 #web-crawler
#python-2.7 #веб-сканер
Вопрос:
1.
<p class="followText">Follow us</p>
<p><a class="symbol ss-social-circle ss-facebook" href="http://www.facebook.com/HowStuffWorks" target="_blank">Facebook</a></p>
2.
<p>Gyroscopes can be very perplexing objects because they move in peculiar ways and even seem to defy gravity. These special properties make gyroscopes extremely important in everything from your <a href="bicycle.htm">bicycle</a> to the advanced navigation system on the <a href="http://science.howstuffworks.com/space-shuttle.htm">space shuttle</a>. A typical <a href="airplane.htm">airplane</a> uses about a dozen gyroscopes in everything from its <a href="compass.htm">compass</a> to its autopilot. The Russian Mir space station used 11 gyroscopes to keep its orientation to <a href="http://science.howstuffworks.com/sun.htm">the sun</a>, and the <a href="http://science.howstuffworks.com/hubble.htm">Hubble Space Telescope</a> has a batch of navigational gyros as well. Gyroscopic effects are also central to things like <a href="http://entertainment.howstuffworks.com/yo-yo.htm">yo-yos</a> and Frisbees!</p>
Это часть исходного кода веб-сайтаhttp://science.howstuffworks.com/gyroscope.htm , из которого я пытаюсь извлечь содержимое <p>
тега.
Это код, который я использую для этого
def trade_spider(max_pages):
page = 1
while page <= max_pages:
url = 'http://science.howstuffworks.com/gyroscope' str(page) ".htm"
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for link in soup.findAll('p'):
paragraph = link.string
print paragraph
Но я получаю оба типа данных (как 1, так и 2) внутри p
тега.
Мне нужно получить только данные из раздела part 2, а не из части 1.
Пожалуйста, предложите мне способ исключить теги с атрибутами, но сохранить базовые теги одного и того же html
тега.