-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path获取知乎热榜标题.py
42 lines (37 loc) · 885 Bytes
/
获取知乎热榜标题.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''
title:
author: team317
Date: 2022-03-22
categories:
- ""
tags:
- ""
'''
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 29 17:58:02 2021
@author: Team317
"""
# 获取热榜
import requests
from bs4 import BeautifulSoup
from lxml import etree
from pyquery import PyQuery as pq
def test1(headers):
r = requests.get("https://www.zhihu.com/hot",headers = headers)
print(r.text)
if __name__ == '__main__':
headers = {
'accept':'*/*',
'accept-encoding':'gzip, deflate, br',
'accept-language':'zh-CN,zh;q=0.9',
'cookie':'q_c1=2e59e7954ea94fe***',
'referer':'http',
'sec-ch-ua':'" Not A;Brand";v="99***',
'sec-ch-ua-mobile':'?0',
'sec-fetch-dest':'empty',
'sec-fetch-mode':'cors',
'sec-fetch-site':'same-origin',
'user-agent':'Mozilla/5.0 (Windows***',
}
test(headers)