forked from lining0806/PythonSpiderNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpider_Main.py
More file actions
22 lines (20 loc) · 775 Bytes
/
Spider_Main.py
File metadata and controls
22 lines (20 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#coding: utf-8
from scrapy.cmdline import execute
import os
if __name__ == '__main__':
project_name = "Wechatproject"
spider_name = "wechat"
results_name = "results/results.json"
if not os.path.exists(project_name):
print "Please Edit the project files and Run again!!!"
s = "scrapy startproject %s" % project_name
execute(s.split())
else:
print "Start Crawling!!!"
path = os.getcwd() # 获取当前路径
os.chdir(path+"/"+project_name) # 修改当前路径
if os.path.exists(results_name):
os.remove(results_name)
s = "scrapy crawl %s" % spider_name
# s = "scrapy crawl %s -o %s -t json" % (spider_name, results_name)
execute(s.split())