- 帖子
- 5
- 精华
- 0
- 积分
- 42
- 阅读权限
- 10
- 注册时间
- 2020-11-18
- 最后登录
- 2020-12-14
|
#代码如下
import requests
from bs4 import BeautifulSoup
link = 'https://www.zhihu.com/people/you-wu-jun-77/following/questions' #想要爬取的用户的关注的问题
print("知乎关注的问题爬取:")
headers = {
'cookies': 'xxx',
'User-Agent': 'xxx'
}
response = requests.get(link, headers=headers)
soup = BeautifulSoup(response.text, 'lxml')
print(soup)
following_question_list = soup.find_all('div', class_='List-item')
print(following_question_list)
print('-------------')
for following_question in following_question_list:
question = following_question.find('div', class_='QuestionItem-title').text.strip()
data = following_question.select('.ContentItem-status > span')[0].text
answer_num = following_question.select('.ContentItem-status > span')[1].text
following_num = following_question.select('.ContentItem-status > span')[2].text
print(question, data, answer_num, following_num)
|
|