首页 > 解决方案 > Web scraping hidden element with BeautifulSoup

问题描述

I'm trying to scrape a hidden element (the date) on a website with BeautifulSoup. However, I keep getting a None type or this output: <span class="hidden-lists">-</span>. Any help would be greatly appreciated!

This is how the relevant part looks on the website:

 <div class="by C C4">
      <span class="hidden-lists">Oct 8, 2018</span>

This is the relevant portion of my code:

 target_3 = page_soup.find("span", attrs={"class": "hidden-lists"})
 print(target_3)

标签: python-3.xweb-scrapingbeautifulsoup

解决方案


这里:

target_3.text.strip()
print(target_3)

我不确定这是否会完全解决您的问题,但请试一试。


推荐阅读