非常抱歉,可能是我在回答时出现了一些笔误。以下是修改后的代码:
```python
import requests
from bs4 import BeautifulSoup
keyword = '甲流'
page_num = 100
for page in range(1, page_num+1):
url = f'https://s.weibo.com/weibo?q={keyword}&typeall=1&suball=1×cope=custom:2022-01-01-0:2022-12-31-23&page={page}'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
cards = soup.find_all('div', class_='card-wrap')
for card in cards:
# 获取微博内容和发布时间
content = card.find('p', class_='txt').text.strip()
time = card.find('p', class_='from').find_all('a')[-1].text.strip()
print(content, time)
```
如果还有问题,请随时提出,我会尽快回复并解决。