teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

誤記修正

2021/05/05 12:28

投稿

Y.H.
Y.H.

スコア7918

answer CHANGED
@@ -5,7 +5,7 @@
5
5
  // ・・・略・・・
6
6
 
7
7
  // $html = file_get_contents('ページのURL');
8
- //↓以下行に置換え
8
+ //↓以下5行に置換え
9
9
  $conn = curl_init(); // cURLセッションの初期化
10
10
  curl_setopt($conn, CURLOPT_URL, $url); // 取得するURLを指定
11
11
  curl_setopt($conn, CURLOPT_RETURNTRANSFER, true); // 実行結果を文字列で返す。

2

誤記修正

2021/05/05 12:28

投稿

Y.H.
Y.H.

スコア7918

answer CHANGED
@@ -1,4 +1,4 @@
1
- file_get_contents()をcurl_init()からcurl_exec()までの5行と置換えるだけでは?
1
+ file_get_contents()をcurl_init()からcurl_close()までの5行と置換えるだけでは?
2
2
 
3
3
  ```php
4
4
  <?php

1

回答訂正

2021/05/05 10:58

投稿

Y.H.
Y.H.

スコア7918

answer CHANGED
@@ -1,4 +1,4 @@
1
- file_get_contents()をcurl_init()からcurl_exec()までの行と置換えるだけでは?
1
+ file_get_contents()をcurl_init()からcurl_exec()までの行と置換えるだけでは?
2
2
 
3
3
  ```php
4
4
  <?php
@@ -10,6 +10,7 @@
10
10
  curl_setopt($conn, CURLOPT_URL, $url); // 取得するURLを指定
11
11
  curl_setopt($conn, CURLOPT_RETURNTRANSFER, true); // 実行結果を文字列で返す。
12
12
  $html = curl_exec($conn);
13
+ curl_close($conn); //セッションの終了
13
14
 
14
15
  $start_leng = mb_strpos($html,'<div id="news">') ;
15
16
  $end_leng = mb_strpos($html,'</div><!-- #news -->') - $start_leng ;