-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
73 lines (70 loc) · 2.24 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
from scrapy.cmdline import execute
if __name__ == "__main__":
config = [
{
"request": {
"type": "api",
"url": "https://www.agedm.org/detail/20100003",
"method": "GET",
"iteration_times": "1",
"dont_filter": "True",
},
"response": {
"type": "html",
"save_fields": [],
"fields": [
{
"name": "name",
"type": "str",
"save_length": "0",
"value": '缘之空 - {xpath://div[@id="playlist-source-panda"]//li/a/text()}',
"default": "",
"save_method": "replace",
"after_process": [],
},
{
"name": "next_url",
"type": "str",
"save_length": "0",
"value": '{xpath://div[@id="playlist-source-panda"]//li/a/@href}',
"default": "",
"save_method": "replace",
"after_process": [],
},
],
},
},
{
"request": {
"type": "api",
"method": "GET",
"iteration_times": "1",
"dont_filter": "True",
"headers": {"host": "www.agedm.org"},
},
"response": {
"type": "html",
"save_fields": ["name", "page_url"],
"fields": [
{
"name": "page_url",
"type": "str",
"save_length": "0",
"value": '{xpath://iframe[@id="iframeForVideo"]/@src}',
"default": "",
"save_method": "replace",
"after_process": [],
}
],
},
},
]
execute(
[
"scrapy",
"crawl",
"base_spider",
"-a",
"config=" + str(config),
]
)