Skip to content

Commit fa76be5

Browse files
JINGJING
authored andcommitted
使用多线程,修复大量bug
1 parent 6fcff9f commit fa76be5

2 files changed

Lines changed: 20 additions & 48 deletions

File tree

comic-update-multithreading.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@
55

66
time_start = time.time()
77

8-
regex = re.compile(r"img\s+src=([^\s]+)\s+alt=([^\/]+)")
8+
regex = re.compile(r"img\s+src=\"([^\"]+)\"\s+alt=\"([^\"]+)")
99
regex2 = re.compile(r"span\s+class=\"gray12\">([^<]+)")
10-
regex3 = re.compile(r"a\s+href=[^\s]+\s+target=[^\s]+\s+title=[^\s]+\s+class=[^>]+>([^<]+)")
11-
regex4 = re.compile(r"<li>([^<]+)")
12-
regex5 = re.compile(r"a\s+target=[^s]+\s+title=[^\s]+\s+href=([^>]+)>([^<]+)")
10+
regex3 = re.compile(r"a\s+href=\"[^\"]+\"\s+target=\"[^\"]+\"\s+title=\"[^\"]+\"\s+class=\"[^\"]\"\s+>([^<]+)")
11+
regex4 = re.compile(r"<li>([^<\+]+)")
12+
regex5 = re.compile(r"a\s+target=\'[^\']+\'\s+title=\"([^(\")]+)\"\s+href=\"([^\"]+)\"s*>")
1313
regex6 = re.compile(r"^\/([^\/]+/)")
1414
regex7 = re.compile(r"\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}")
1515

16+
#regex = re.compile(r"img\s+src=([^\s]+)\s+alt=([^\/]+)")
17+
#regex2 = re.compile(r"span\s+class=\"gray12\">([^<]+)")
18+
#regex3 = re.compile(r"a\s+href=[^\s]+\s+target=[^\s]+\s+title=[^\s]+\s+class=[^>]+>([^<]+)")
19+
#regex4 = re.compile(r"<li>([^<]+)")
20+
#regex5 = re.compile(r"a\s+target=[^s]+\s+title=[^\s]+\s+href=([^>]+)>([^<]+)")
21+
#regex6 = re.compile(r"^\/([^\/]+/)")
22+
#regex7 = re.compile(r"\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}")
23+
1624
conf = ConfigParser.ConfigParser()
1725
conf.read("conf_comic")
1826
section = "dmzj"
@@ -47,7 +55,7 @@ def run(self):
4755

4856
#封面图片地址,漫画名
4957
for x in regex.findall(content):
50-
self.data.append([x[0].replace("\"", ""), x[1].replace("\"", ""), "2", "3", "4", "5", "6", "7", "8"])
58+
self.data.append([x[0], x[1], "2", "3", "4", "5", "6", "7", "8"])
5159

5260
self.maxsize = len(self.data)
5361

@@ -64,9 +72,9 @@ def run(self):
6472
elif(i == 4):
6573
self.data[p][4] = x
6674
p += 1
67-
elif(i % 3 == 1):
68-
self.data[p][3] = x
6975
elif(i % 3 == 2):
76+
self.data[p][3] = x
77+
elif(i % 3 == 1):
7078
self.data[p][4] = x
7179
p += 1
7280

@@ -75,17 +83,18 @@ def run(self):
7583

7684
#更新卷
7785
for i, x in enumerate(regex5.findall(content)):
78-
self.data[i][5] = cfgDmjz["root"] + x[0].replace("\"", "")
79-
self.data[i][6] = x[1]
80-
self.data[i][7] = cfgDmjz["root"] + "/" + regex6.findall(x[0].replace("\"", ""))[0]
86+
self.data[i][5] = cfgDmjz["root"] + x[1]
87+
self.data[i][6] = x[0]
88+
self.data[i][7] = cfgDmjz["root"] + "/" + regex6.findall(x[1])[0]
8189

8290

8391
#更新时间
8492
for i, x in enumerate(regex7.findall(content)):
8593
self.data[i][8] = x
8694

8795
except Exception, e:
88-
pass
96+
#pass
97+
print e
8998

9099
thread_pool = []
91100
for i, x in enumerate(update_list):

threading.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)