Python bs4 find_all()不显示我在HTML中查找的文本

Python bs4 find_all()不显示我在HTML中查找的文本,python,html,beautifulsoup,python-requests,Python,Html,Beautifulsoup,Python Requests,我使用Python BeautifulSoup4和请求从以下网站获取数据:。我想让我的程序从中返回文本,但我的输出中什么也没有得到 这是我的密码: import requests as r from bs4 import BeautifulSoup as bs doc = r.get("http://www.weather.gov/ctp/") soup = bs(doc.content, "html.parser") # I tried all of these methods to get

我使用Python BeautifulSoup4和请求从以下网站获取数据:。我想让我的程序从中返回文本,但我的输出中什么也没有得到

这是我的密码:

import requests as r
from bs4 import BeautifulSoup as bs
doc = r.get("http://www.weather.gov/ctp/")
soup = bs(doc.content, "html.parser")
# I tried all of these methods to get "Weather.gov" as a returned string but none of them worked!
link1 = soup.find_all('href="http://www.weather.gov"')
link2 = soup.find_all("a", {'href':'http://www.weather.gov'})
link3 = soup.select('href["http://www.weather.gov"]')
for item in link3:
    print item.contents
# This loop does not return anything in the console
我试着用同样的方法从网站的另一部分检索文本,结果成功了。我在另一个网站上遇到了同样的问题,但这次是一个数字。我试图将这个数字作为一个可以分配给变量的值来检索,但我什么也得不到,尽管在测试了一个值的输出后,我得到了True,但在控制台中什么也没有

汤。选择'a[href]=http://www.weather.gov]"

标记[attribute='attribute\u value']


更多信息,请访问链接2 works。其他链接只是不正确的选择器。感谢您的启发