Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nueip/curl
NUEiP Curl Lib
https://github.com/nueip/curl
crawler php
Last synced: about 1 month ago
JSON representation
NUEiP Curl Lib
- Host: GitHub
- URL: https://github.com/nueip/curl
- Owner: nueip
- License: mit
- Created: 2019-11-15T07:02:45.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-13T06:05:01.000Z (over 3 years ago)
- Last Synced: 2024-10-25T19:55:43.564Z (2 months ago)
- Topics: crawler, php
- Language: PHP
- Homepage:
- Size: 57.6 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# curl-helper
### Default Parameters
```php
$config = [
// Title for recognize
title => '',
// Targe url
url => '',
// Request method
type => '',
// Request argements
data => [],
// Extra curl options
curlOpt => [],
// Cookie content
cookies => [],
];
```### Excute Crawler
```php
// Set config
$config = new CrawlerConfig([
'title' => '',
'url' => '',
'type' => '',
'data' => [],
'curlOpt' => [],
'cookies' => [],
]);// Execute crawler
$result = Crawler::run($config)
```### Data
| id | username | password | email |
| ---- | -------- | ---------- | ----------------- |
| 5241 | admin | 123456 | [email protected] |
| 6542 | user1 | user1_pass | [email protected] |
| 6543 | user2 | user2_pass | [email protected] |---
## Example
### Get method
#### List all data
- Example:
```php
$config = new CrawlerConfig([
'title' => 'List all data',
'url' => 'https://example.com/tests/fakeWeb/index.php',
'type' => 'get',
]);$result = Crawler::run($config);
```
- Output:
```php
$result = [
'code' => 200,
'message' => 'success',
'data' => [
'5241' => [
'id' => 5241,
'username' => 'admin',
'password' => '123456',
'email' => '[email protected]'
],
'6542' => [
'id' => 6542,
'username' => 'user1',
'password' => 'user1_pass',
'email' => '[email protected]'
],
'6543' => [
'id' => 6543,
'username' => 'user2',
'password' => 'user2_pass',
'email' => '[email protected]'
]
]
];
```#### List someone data
- example
```php
$config = new CrawlerConfig([
'title' => 'List someone member',
'url' => 'https://example.com/tests/fakeWeb/index.php?id=6543',
'type' => 'get',
]);$result = Crawler::run($config);
```
- Output
```php
$result = [
'code' => 200,
'message' => 'success',
'data' => [
'id' => 6543,
'username' => 'user2',
'password' => 'user2_pass',
'email' => '[email protected]'
]
];
```### Post method
#### login
- example
```php
$config = new CrawlerConfig([
'title' => 'Login',
'url' => 'https://example.com/tests/fakeWeb/index.php',
'type' => 'post',
'data' => [
'username' => 'admin',
'password' => '123456',
]
]);$result = Crawler::run($config);
```
- Output:
```php
$result = [
'code' => 200,
'message' => 'Login success',
];
```### Put method
#### Edit data
- example
```php
$config = new CrawlerConfig([
'title' => 'Edit data',
'url' => 'https://example.com/tests/fakeWeb/index.php',
'type' => 'put',
'data' => [
'id' => '1234',
'email' => '[email protected]',
],
]);$result = Crawler::run($config);
```
- Output
```php
$result = [
'code' => 200,
'message' => 'success',
'data' => [
'id' => '1234',
'email' => '[email protected]',
'username' => 'admin',
'password' => '123456'
]
];
```