爬虫运行成,但没有输出结果

代码能运行,但是没有输出结果,哪里出问题了呢

```python

# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
}
respone=requests.get("https://www.mfa.gov.cn/irs-c-web/search.shtml?code=17e50b77dab&dataTypeId=15&searchBy=title&searchWord=%E6%AC%A2%E4%B9%90%E6%98%A5%E8%8A%82")
html=respone.text
soup=BeautifulSoup(html,"html.parser")
all_times=soup.findAll("span",attrs={"class":"sourceTime"})
for time in all_times:
    print(time.string)

```

如果你的程序正确,可能是你的编译器问题,因为编译器经常有这个bug。还有你仔细检查检查程序,因为虽然运行了,但不代表就能输出你想要的结果

网页是动态的,requests获取不到数据
通过api接口

import requests
import pandas as pd
import json
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'}
json_data = {
    'code': '17e50b77dab',
    'configCode': '',
    'codes': '',
    'searchWord': '欢乐春节',
    'dataTypeId': '15',
    'orderBy': 'time',
    'searchBy': 'title',
    'appendixType': '',
    'granularity': 'ALL',
    'beginDateTime': '',
    'endDateTime': '',
    'isSearchForced': 0,
    'filters': [],
    'pageNo': 1,
    'pageSize': 10,
}

response = requests.post('https://www.mfa.gov.cn/irs/front/search', headers=headers, json=json_data)
d=json.loads(response.text)['data']['middle']['list']
data=pd.DataFrame(d)
print(data['time'])

img

img