python-3.x - 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)
解决方案
这里:
target_3.text.strip()
print(target_3)
我不确定这是否会完全解决您的问题,但请试一试。
推荐阅读
- reactjs - 反应,Firebase 身份验证错误
- c++ - 在 Visual C++ 中显示日文字符
- ionic-framework - 从 HTTP 正文响应中获取特定数据
- actionscript-3 - 从纹理图集中调用精灵而不在动作脚本 3 中使用八哥
- php - 使用 PHP 将文件从目录移动到另一个目录
- angularjs - 将 json 传递给角度控制器
- python - 为什么我收到此烧瓶页面的错误请求错误?
- reactjs - 如何创建将在包之间直接使用的 ts 文件的 typescript monorepo
- c# - 将 Json 文件更新为函数 c#
- javascript - rhino javascript在调试期间尝试捕获范围