-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
154 lines (111 loc) Β· 3.31 KB
/
main.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import jsons
from parsers import (
kwejk,
jbzd,
demoty,
mistrzowie,
anonimowe,
ninegag,
ifunnyco,
faktopedia,
)
from flask import Flask
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
def to_response(page):
return jsons.dumps(page)
@app.route("/")
def hello():
return to_response(
[
"/kwejk",
"/jbzd",
"/9gag",
"/9gagnsfw",
"/demotywatory",
"/mistrzowie",
"/anonimowe",
"/ifunnyco",
"/faktopedia",
]
)
@app.route("/kwejk")
def kwejk_root():
return to_response(kwejk.scrap("https://kwejk.pl"))
@app.route("/kwejk/page/<page>")
def kwejk_page(page):
return to_response(kwejk.scrap("https://kwejk.pl/strona/{}".format(page)))
@app.route("/jbzd")
def jbzd_root():
return to_response(jbzd.scrap("https://jbzd.com.pl"))
@app.route("/jbzd/page/<page>")
def jbzd_page(page):
return to_response(jbzd.scrap("https://jbzd.com.pl/str/{}".format(page)))
@app.route("/mistrzowie")
def mistrzowie_root():
return to_response(mistrzowie.scrap("http://mistrzowie.org"))
@app.route("/mistrzowie/page/<page>")
def mistrzowie_page(page):
return to_response(mistrzowie.scrap("http://mistrzowie.org/page/{}".format(page)))
@app.route("/anonimowe")
def anonimowe_root():
return to_response(anonimowe.scrap("https://anonimowe.pl"))
@app.route("/anonimowe/page/<page>")
def anonimowe_page(page):
return to_response(anonimowe.scrap("https://anonimowe.pl/{}".format(page)))
@app.route("/demotywatory")
def demotywatory_root():
return to_response(demoty.scrap("https://m.demotywatory.pl"))
@app.route("/demotywatory/page/<page>")
def demotywatory_page(page):
return to_response(demoty.scrap("https://m.demotywatory.pl/page/{}".format(page)))
@app.route("/faktopedia")
def faktopedia_root():
return to_response(faktopedia.scrap("https://m.faktopedia.pl"))
@app.route("/faktopedia/page/<page>")
def faktopedia_page(page):
return to_response(faktopedia.scrap("https://m.faktopedia.pl/page/{}".format(page)))
@app.route("/9gag")
def ninegag_root():
return to_response(
ninegag.scrap("https://9gag.com/v1/group-posts/group/default/type/hot")
)
@app.route("/9gag/page/<page>")
def ninegag_page(page):
return to_response(
ninegag.scrap(
"https://9gag.com/v1/group-posts/group/default/type/hot?c=10&after={}".format(
page
)
)
)
@app.route("/9gagnsfw")
def ninegagnsfw_root():
return to_response(
ninegag.scrap("https://9gag.com/v1/group-posts/group/nsfw/type/hot", nsfw=True)
)
@app.route("/9gagnsfw/page/<page>")
def ninegagnsfw_page(page):
return to_response(
ninegag.scrap(
"https://9gag.com/v1/group-posts/group/nsfw/type/hot?c=10&after={}".format(
page
),
nsfw=True,
)
)
@app.route("/ifunnyco")
def ifunnyco_root():
return to_response(
ifunnyco.scrap("https://ifunny.co/api/v1/feeds/featured?page=1", 1)
)
@app.route("/ifunnyco/page/<page>")
def ifunnyco_page(page):
return to_response(
ifunnyco.scrap(
"https://ifunny.co/api/v1/feeds/featured?page={}".format(page), page
)
)
if __name__ == "__main__":
app.run(debug=True)