3
4

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.

今更、phpでweb scraping

Posted at

やりたいこと

LINEグループ内で、金曜ロードショーの予定を表示したい

こんな感じ

image.png

やったこと

最初に「テレビ番組検索」用APIを探したが見つけることが出来なかったので、
金曜ロードショーのサイトを直接、Web scrapingするプログラムを作成した。

プログラム

金曜ロードショーのWEBサイトが綺麗に作成されているため、以下の10行程度で簡単に作成できました。

確認用
<?php
$html = file_get_contents('https://kinro.jointv.jp/lineup');
$data = phpQuery::newDocument($html);
foreach( $data['.cap'] as $line) {
    $date  = pq($line)->find('.date')->text();
    $title = pq($line)->find('.title')->text();
    $en    = pq($line)->find('.en')->text();
    printf( "%s:%s(%s)\n", $date, $title, $en);
}
  • LINE側のコーディングはもう少し効率よく書けるようになったら公開したいと思います。
3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?