Skip to content

Commit eb10a37

Browse files
committed
update english docs
1 parent f11bb37 commit eb10a37

File tree

3 files changed

+37
-29
lines changed

3 files changed

+37
-29
lines changed

Docs/README.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
## Usage: Depend On The PHPCreeper Application Framework
3-
Now, let's do the same job based on the Application Framework:
3+
Now, let's do the same job based on the PHPCreeper Application Framework:
44

55

66
#### *Step-1:Download PHPCreeper-Application Framework*
@@ -32,27 +32,28 @@ php Application/Sbin/Creeper
3232

3333
#### *Step-4:Create One Application*
3434

35-
1、Create one spider application named **github**:
35+
1、Create one spider application named **weather**:
3636
```
37-
php Application/Sbin/Creeper make github --en
37+
php Application/Sbin/Creeper make weather --en
3838
```
3939

4040
2、The complete execution process looks like this:
41-
![AppAssistant](/Image/AppGithubEnglish.png)
4241

43-
As matter of fact, we have accomplished all the jobs at this point,
44-
you just need to run `php github.php start` to see what has happened,
45-
but you still need to finish the rest step of the work if you wanna
42+
![AppWeather2English](/Image/AppWeather2English.png)
43+
44+
In fact, we have done all the jobs at this point,
45+
now you just need to run `php weather.php start` to see what has happened,
46+
but you still need to finish the rest step of the work if you want to
4647
do some elaborate work or jobs.
4748

4849
#### *Step-5:Business Configuration*
4950
1、Switch to the application config direcory:
5051
```
51-
cd Application/Spider/Github/Config/
52+
cd Application/Spider/Weather/Config/
5253
```
5354
2、Edit the global config file named **global.php**:
5455
```
55-
Normally, there is no need to change this file unless you wanna create a new global sub-config file
56+
Basically, there is no need to change this file unless you want to create a new global sub-config file
5657
```
5758
3、Edit the global sub-config file named **database.php**:
5859
```php
@@ -62,7 +63,7 @@ return [
6263
'host' => '127.0.0.1',
6364
'port' => 6379,
6465
'database' => 0,
65-
'prefix' => 'Github',
66+
'prefix' => 'Weather',
6667
],
6768
];
6869
```
@@ -74,7 +75,7 @@ return [
7475
'host' => '127.0.0.1',
7576
'port' => 6379,
7677
'database' => 0,
77-
'prefix' => 'Github',
78+
'prefix' => 'Weather',
7879
]],
7980
];
8081
```
@@ -95,9 +96,9 @@ return array(
9596

9697
//whether to start the given worker(s) instance or not(optional, default `true`)
9798
'start' => array(
98-
'GithubProducer' => true,
99-
'GithubDownloader' => true,
100-
'GithubParser' => true,
99+
'AppProducer' => true,
100+
'AppDownloader' => true,
101+
'AppParser' => true,
101102
),
102103

103104
//global task config
@@ -110,7 +111,7 @@ return array(
110111

111112
//specifies the max number of connections each downloader process can connect to the parser
112113
//(optional, default `1`, minimum value 1, maximum value 1000)
113-
//'max_connections' => 1,
114+
'max_connections' => 1,
114115

115116
//set the max number of the request for each socket connection,
116117
//if the cumulative number of socket requests exceeds the max number of requests,
@@ -213,12 +214,13 @@ return array(
213214

214215
//set the initialized task, support both Single-Task and Multi-Task
215216
'task_init' => array(
216-
'url' => 'https://github.com/search?q=stars:%3E1&s=stars&type=Repositories',
217+
'url' => "https://forecast.weather.gov/MapClick.php?lat=47.4113&lon=-120.5563",
217218

218219
//please refer to the "How to set extractor rule" section for details
219220
"rule" => array(
220-
'title' => ['ul.repo-list div.f4.text-normal > a', 'text'],
221-
'stars' => ['ul.repo-list div.mr-3:nth-of-typ(1) > a', 'text'],
221+
'period' => ['#seven-day-forecast-container ul li p.period-name', 'text'],
222+
'weather' => ['#seven-day-forecast-container ul li p.short-desc', 'text'],
223+
'temperature' => ['#seven-day-forecast-container ul li p.temp', 'text'],
222224
),
223225

224226
//set rule name which will be set to `md5($task_id)` if leave it empty
@@ -305,20 +307,22 @@ public function onDownloaderReload($downloader)
305307
{
306308
}
307309

310+
public function onDownloaderConnectToParser($connection)
311+
{
312+
}
313+
308314
public function onDownloaderMessage($downloader, $parser_reply)
309315
{
310316
}
311317

312318
public function onDownloadBefore($downloader, $task)
313319
{
314320
//here we can reset the $task and then return it
315-
//$task = [...];
316321
//return $task;
317322

318323
//here we can change the context parameters when creating a http request
319-
//$downloader->httpClient->setConnectTimeout(3);
324+
//$downloader->httpClient->setConnectTimeout(5);
320325
//$downloader->httpClient->setTransferTimeout(10);
321-
//$downloader->httpClient->setProxy('http://180.153.144.138:8800');
322326
//$downloader->httpClient->disableSSL();
323327
}
324328

@@ -335,6 +339,10 @@ public function onDownloadAfter($downloader, $download_data, $task)
335339
public function onDownloadFail($downloader, $error, $task)
336340
{
337341
}
342+
343+
public function onTaskEmpty($downloader)
344+
{
345+
}
338346
```
339347
3、Write business callback for AppParser:
340348
```php
@@ -383,13 +391,13 @@ it can be distributed or deployed separately.
383391

384392
1、Or Global Startup:
385393
```
386-
php github.php start
394+
php weather.php start
387395
```
388396

389397
2、Or Single Startup:
390398
```
391-
php Application/Spider/Github/AppProducer.php start
392-
php Application/Spider/Github/AppDownloader.php start
393-
php Application/Spider/Github/AppParser.php start
399+
php Application/Spider/Weather/Start/AppProducer.php start
400+
php Application/Spider/Weather/Start/AppDownloader.php start
401+
php Application/Spider/Weather/Start/AppParser.php start
394402
```
395403

Image/AppWeather2English.png

58.7 KB
Loading

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ $config['redis'] = [
144144
'prefix' => 'PHPCreeper',
145145
'connection_timeout' => 5,
146146
'read_write_timeout' => 0,
147-
'use_red_lock' => true, //default to true since v1.6.4
147+
'use_red_lock' => true,
148148
],
149149
];
150150

@@ -322,21 +322,21 @@ $rule = array(
322322

323323
//Single-Task
324324
$task = array(
325-
'url' => 'http://www.weather.com.cn/weather/101010100.shtml',
325+
'url' => "https://forecast.weather.gov/MapClick.php?lat=47.4113&lon=-120.5563",
326326
'rule' => $rule,
327327
'rule_name' => 'r1',
328328
);
329329

330330
//Multi-Task
331331
$task = array(
332332
array(
333-
'url' => 'http://www.weather.com.cn/weather/101010100.shtml',
333+
'url' => "https://forecast.weather.gov/MapClick.php?lat=47.4113&lon=-120.5563",
334334
'rule' => $rule,
335335
'rule_name' => 'r1',
336336
"context" => $context,
337337
),
338338
array(
339-
'url' => 'http://www.weather.com.cn/weather/201010100.shtml',
339+
'url' => "https://forecast.weather.gov/MapClick.php?lat=47.4113&lon=-120.5563",
340340
'rule' => $rule,
341341
'rule_name' => 'r2',
342342
"context" => $context,

0 commit comments

Comments
 (0)