写一份代码实现微博实时追踪陈奕迅的最新消

时间2023-04-26 15:49:07 提问来自 加州洛杉矶 的网友 分类ChatGPT提问 浏览190 热度0
import requests from bs4 import BeautifulSoup import re url = 'https://s.weibo.com/user?q=%E9%99%88%E5%A5%95%E8%BF%85&Refer=weibo_user' # 微博搜索陈奕迅的链接 response = requests.get(url) html = response.text soup = BeautifulSoup(html, 'lxml') # 解析HTML代码 item_list = soup.find_all('div', {'class': 'card-wrap'}) # 找到所有卡片,这里是微博发布内容的位置 for item in item_list: # 遍历所有卡片,获取内容 weibo_content = item.find('p', {'class': 'txt'}).text # 获取微博正文 weibo_time = item.find('p', {'class': 'from'}).text # 获取微博时间 print('微博正文:{}\n'.format(weibo_content)) print('微博时间:{}\n'.format(weibo_time))

AI智能问答网免责声明:
以上内容除特别注明外均来源于网友提问、ChatGPT回答,权益归原著者所有,本站仅作效果演示和欣赏之用;
若以上展示有冒犯或侵害到您,敬请联系我们进行删除处理,谢谢!

上一篇 合作合同中的合伙人负责人应该怎么写 下一篇 搜索框的用法