2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

電大UNIPAログインPHPスクリプト

Posted at

脳を停止しても出来る方法

使うもの

  • PHP
  • Goutte
  • composer

まず設定ファイル

keys.php
<?php
// TODO: write this
define('TDU_USER_ID', '*******');
define('TDU_USER_PW', '************');

keys.php に保存
もちろんこのファイルは絶対に公開してはいけない

composer.jsonに以下を追加

composer.json
    "require": {
        "fabpot/goutte": "~2.0"
    }
composer install

実行スクリプト

marco.php

require_once('./vendor/autoload.php');
require_once('./keys.php');
use Goutte\Client;

$client = new Client();
$url = 'https://portal.sa.dendai.ac.jp/up/faces/login/Com00504A.jsp';

$crawler = $client->request('GET', $url);
if ($logout_btn = $crawler->selectButton('form1:logout')) {
    // セッションタイムアウトページの場合
    $crawler = $client->submit($logout_btn->form(), array());
}

// submitするform
$form = $crawler->selectButton('form1:login')->form();
// POSTするパラメータ
$params = array(
    'form1:htmlUserId' => TDU_USER_ID,
    'form1:htmlPassword' => TDU_USER_PW
);
$crawler = $client->submit($form, $params);
$username = $crawler->filter('span')->text();
echo $username . "\n";

出力

◯◯ ◯◯ さん : 前回ログイン 2015/01/17 00:47

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?