Skip to content

Commit

Permalink
20个进程同时下载
Browse files Browse the repository at this point in the history
  • Loading branch information
KilluaaaCHEN committed Apr 7, 2017
1 parent 281051b commit 0d804fc
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 96 deletions.
14 changes: 11 additions & 3 deletions DownloadAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
class DownloadAll
{
public function down()
public function down($start = 1)
{
$url = 'https://www.doutula.com/photo/list/?page=';

Expand All @@ -16,12 +16,19 @@ public function down()
mkdir($store_path);
}

for ($i = 1; ; $i++) {
$is_cs = false;//是否重试

for ($i = $start; ; $i++) {
$content = $this->get($url . $i);
preg_match_all('/data-original\=\"\/\/([\s\S]*?)\"/', $content, $img_list);
if (count($img_list[1]) < 10) {
if (!$is_cs) {
$i--;
continue;
}
break;
}
$is_cs = false;
foreach ($img_list[1] as $img) {
$file_path = $store_path . md5($img) . '.png';
if (!file_exists($file_path)) {
Expand All @@ -47,5 +54,6 @@ public function get($url)

}

(new DownloadAll())->down();
$start = intval($argv[1]);
(new DownloadAll())->down($start);
exit;
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

### 检索关键字: `dt`

### 下载所有图片关键字: `dadt`
### 下载所有图片关键字: `dadt` ,近20个进程同时下载

### 查看已下载图片数:`ls ~/Pictures/.DouTu | wc -w`

### 图片默认保存在`~/Pictures/.DouTu/`下面

### 不要了可以直接删掉`rm -rf ~/Pictures/.DouTu`

### 想修改图片保存路径可以修改`config.php`文件
Expand Down
1 change: 1 addition & 0 deletions cache.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
熊本熊
165 changes: 73 additions & 92 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,7 @@
</dict>
</array>
<key>3F7DE7ED-1859-4F14-B259-9452CA0F00D4</key>
<array>
<dict>
<key>destinationuid</key>
<string>2CF17673-5F11-473E-B03C-DB04892EB87A</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<array/>
<key>A105DBAE-3853-4BD8-8B07-0DF05C715F9E</key>
<array/>
<key>B2766B5C-9C5D-4BE4-A748-35C43FCD5C7C</key>
Expand Down Expand Up @@ -143,6 +132,37 @@
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>action</key>
<integer>0</integer>
<key>argument</key>
<integer>0</integer>
<key>focusedappvariable</key>
<false/>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>2</integer>
<key>hotmod</key>
<integer>655360</integer>
<key>hotstring</key>
<string>D</string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
<integer>0</integer>
<key>relatedAppsMode</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.hotkey</string>
<key>uid</key>
<string>B2766B5C-9C5D-4BE4-A748-35C43FCD5C7C</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -187,35 +207,12 @@
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>action</key>
<integer>0</integer>
<key>argument</key>
<integer>0</integer>
<key>focusedappvariable</key>
<false/>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>2</integer>
<key>hotmod</key>
<integer>655360</integer>
<key>hotstring</key>
<string>D</string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
<integer>0</integer>
<key>relatedAppsMode</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.hotkey</string>
<string>alfred.workflow.action.revealfile</string>
<key>uid</key>
<string>B2766B5C-9C5D-4BE4-A748-35C43FCD5C7C</string>
<string>73C71487-6079-42CA-831B-3E959C6BAE2F</string>
<key>version</key>
<integer>2</integer>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
Expand Down Expand Up @@ -263,14 +260,6 @@
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>type</key>
<string>alfred.workflow.action.revealfile</string>
<key>uid</key>
<string>73C71487-6079-42CA-831B-3E959C6BAE2F</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand All @@ -297,21 +286,21 @@
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<false/>
<key>removeextension</key>
<false/>
<key>argumenttype</key>
<integer>2</integer>
<key>keyword</key>
<string>dadt</string>
<key>subtext</key>
<string>可能需要一段时间...5万多张</string>
<key>text</key>
<string></string>
<key>title</key>
<string>所有图片下载完成 - 斗图神器</string>
<string>下载所有图图片-斗图神器</string>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>2CF17673-5F11-473E-B03C-DB04892EB87A</string>
<string>03F0F61A-BDC4-4F63-8F6E-DFF5E4D5396A</string>
<key>version</key>
<integer>1</integer>
</dict>
Expand All @@ -323,7 +312,27 @@
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>php DownloadAll.php</string>
<string>php DownloadAll.php 1&amp;
php DownloadAll.php 150&amp;
php DownloadAll.php 100&amp;
php DownloadAll.php 150&amp;
php DownloadAll.php 200&amp;
php DownloadAll.php 250&amp;
php DownloadAll.php 300&amp;
php DownloadAll.php 350&amp;
php DownloadAll.php 400&amp;
php DownloadAll.php 450&amp;
php DownloadAll.php 500&amp;
php DownloadAll.php 550&amp;
php DownloadAll.php 600&amp;
php DownloadAll.php 650&amp;
php DownloadAll.php 700&amp;
php DownloadAll.php 750&amp;
php DownloadAll.php 800&amp;
php DownloadAll.php 850&amp;
php DownloadAll.php 900&amp;
php DownloadAll.php 950&amp;
php DownloadAll.php 1000&amp;</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
Expand All @@ -338,27 +347,6 @@
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argumenttype</key>
<integer>2</integer>
<key>keyword</key>
<string>dadt</string>
<key>subtext</key>
<string>可能需要一段时间...5万多张</string>
<key>text</key>
<string>下载所有图图片-斗图神器</string>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>03F0F61A-BDC4-4F63-8F6E-DFF5E4D5396A</string>
<key>version</key>
<integer>1</integer>
</dict>
</array>
<key>readme</key>
<string>Keywords are one of Alfred's most commonly used and most useful ways of launching actions. Set a keyword and connect it to the action(s) you want to perform.
Expand All @@ -371,16 +359,9 @@ Type your keyword into Alfred, followed by your input text if needed, and you'll
<key>note</key>
<string>下载所有图片</string>
<key>xpos</key>
<integer>180</integer>
<key>ypos</key>
<integer>480</integer>
</dict>
<key>2CF17673-5F11-473E-B03C-DB04892EB87A</key>
<dict>
<key>xpos</key>
<integer>530</integer>
<integer>170</integer>
<key>ypos</key>
<integer>480</integer>
<integer>450</integer>
</dict>
<key>3560B2C8-B27E-4452-A9BE-C23592F78025</key>
<dict>
Expand All @@ -394,12 +375,12 @@ Type your keyword into Alfred, followed by your input text if needed, and you'll
<key>xpos</key>
<integer>360</integer>
<key>ypos</key>
<integer>480</integer>
<integer>450</integer>
</dict>
<key>73C71487-6079-42CA-831B-3E959C6BAE2F</key>
<dict>
<key>xpos</key>
<integer>810</integer>
<integer>840</integer>
<key>ypos</key>
<integer>320</integer>
</dict>
Expand All @@ -420,7 +401,7 @@ Type your keyword into Alfred, followed by your input text if needed, and you'll
<key>C00A865B-E24F-4449-9800-1773A74848FB</key>
<dict>
<key>xpos</key>
<integer>650</integer>
<integer>690</integer>
<key>ypos</key>
<integer>320</integer>
</dict>
Expand All @@ -434,7 +415,7 @@ Type your keyword into Alfred, followed by your input text if needed, and you'll
<key>E5AA7E2E-2DD6-4C77-9EDC-9C1F671D3453</key>
<dict>
<key>xpos</key>
<integer>500</integer>
<integer>530</integer>
<key>ypos</key>
<integer>320</integer>
</dict>
Expand Down
Binary file modified 斗图神器.alfredworkflow
Binary file not shown.

0 comments on commit 0d804fc

Please sign in to comment.