阅读(161) 书签 (0)

AIGC提示词:编写爬虫代码,找到满江红影评中的5分好评并点赞

2023-06-29 14:55 更新

使用场景: 代码生成

中文提示词

提供一个爬虫代码,在豆瓣网上找到满江红的影评中5分好评的评论,并进行点赞操作

示例对话

ChatGPT3.5 代码生成

用户

提供一个爬虫代码,在豆瓣网上找到满江红的影评中5分好评的评论,并进行点赞操作

AI模型(ChatGPT3.5)

您需要的爬虫代码是什么语言编写的?

用户

Python

AI模型(ChatGPT3.5)

感谢您提供的信息。您需要的爬虫代码如下:


```python
import requests
from bs4 import BeautifulSoup


url = 'https://movie.douban.com/subject/1291546/comments?start=20&limit=20&sort=new_score&status=P'


headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}


res = requests.get(url, headers=headers)


soup = BeautifulSoup(res.text, 'html.parser')


comments = soup.find_all('span', {'class': 'short'})


for comment in comments:
    if comment.text.strip() == '满江红':
        up = comment.parent.next_sibling.next_sibling
        up.click()
        break



---