-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_sub_pic_or_vid.py
92 lines (87 loc) · 2.16 KB
/
random_sub_pic_or_vid.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import requests
import json
url = "https://api.scrolller.com/api/v2/graphql"
headers = {
"Authority": "api.scrolller.com",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36",
"Content-Type": "text/plain;charset=UTF-8",
"Accept": "*/*",
"Origin": "https://scrolller.com",
"Sec-Fetch-Site": "same-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://scrolller.com/",
"Accept-Language": "en-US,en;q=0.9,fr-FR;q=0.8,fr;q=0.7"
}
# GraphQL query
query = """
query DiscoverSubredditsQuery(
$filter: MediaFilter,
$limit: Int,
$iterator: String,
$hostsDown: [HostDisk]
) {
discoverSubreddits(
isNsfw: true,
filter: $filter,
limit: $limit,
iterator: $iterator
) {
iterator
items {
__typename
url
title
secondaryTitle
description
createdAt
isNsfw
subscribers
isComplete
itemCount
videoCount
pictureCount
albumCount
isFollowing
children(
limit: 2,
iterator: null,
filter: null,
disabledHosts: $hostsDown
) {
iterator
items {
__typename
url
title
subredditTitle
subredditUrl
redditPath
isNsfw
albumUrl
isFavorite
mediaSources {
url
width
height
isOptimized
}
}
}
}
}
}
"""
# Variables for the query
variables = {
"limit": 2,
"filter": None,
"hostsDown": None,
}
data = {
"query": query,
"variables": variables,
"authorization": None
}
response = requests.post(url, headers=headers, json=data)
print(json.dumps(response.json(), indent=4))