Giter VIP home page Giter VIP logo

curl's Introduction

curl-helper

Default Parameters

$config = [
  // Title for recognize
  title => '',
  // Targe url
  url => '',
  // Request method
  type => '',
  // Request argements
  data => [],
  // Extra curl options
  curlOpt => [],
  // Cookie content
  cookies => [],
];

Excute Crawler

// 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:
    $config = new CrawlerConfig([
      'title' => 'List all data',
      'url' => 'https://example.com/tests/fakeWeb/index.php',
      'type' => 'get',
    ]);
    
    $result = Crawler::run($config);
  • Output:
    $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
    $config = new CrawlerConfig([
      'title' => 'List someone member',
      'url' => 'https://example.com/tests/fakeWeb/index.php?id=6543',
      'type' => 'get',
    ]);
    
    $result = Crawler::run($config);
  • Output
    $result = [
      'code' => 200,
      'message' => 'success',
      'data' => [
        'id' => 6543,
        'username' => 'user2',
        'password' => 'user2_pass',
        'email' => '[email protected]'
      ]
    ];

Post method

login

  • example
    $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:
    $result = [
      'code' => 200,
      'message' => 'Login success',
    ];

Put method

Edit data

  • example
    $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
    $result = [
      'code' => 200,
      'message' => 'success',
      'data' => [
        'id' => '1234',
        'email' => '[email protected]',
        'username' => 'admin',
        'password' => '123456'
      ]
    ];

curl's People

Contributors

gunter1020 avatar

Stargazers

SeanLee avatar  avatar

Watchers

James Cloos avatar kigi avatar Nick Lai avatar

Forkers

goobemoo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.