Pythonチュートリアル

Pythonホーム Pythonイントロ Pythonはじめに Python構文 Pythonコメント Python変数 Pythonデータ型 Python番号 Pythonキャスティング Python文字列 Pythonブール値 Python演算子 Pythonリスト Pythonタプル Pythonセット Python辞書 Python If ... Else PythonのWhileループ PythonForループ Python関数 Python Lambda Python配列 Pythonクラス/オブジェクト Pythonの継承 Pythonイテレータ Pythonスコープ Pythonモジュール Pythonの日付 Python数学 Python JSON Python RegEx Python PIP Python試してみてください... Pythonユーザー入力 Python文字列フォーマット

ファイル処理

Pythonファイル処理 Python読み取りファイル Python書き込み/ファイルの作成 Pythonファイルの削除

Pythonモジュール

NumPyチュートリアル パンダ攻略 Scipyチュートリアル

Python Matplotlib

Matplotlibイントロ Matplotlibはじめに Matplotlib Pyplot Matplotlibプロット Matplotlibマーカー Matplotlibライン Matplotlibラベル Matplotlibグリッド Matplotlibサブプロット Matplotlib散布図 Matplotlibバー Matplotlibヒストグラム Matplotlib円グラフ

機械学習

入門 平均中央値モード 標準偏差 パーセンタイル データ配信 正規データ分布 散布図 線形回帰 多項式回帰 重回帰 規模 トレーニング/テスト デシジョンツリー

Python MySQL

MySQLはじめに MySQLデータベースの作成 MySQLテーブルの作成 MySQL挿入 MySQL Select MySQL Where MySQL Order By MySQL削除 MySQLドロップテーブル MySQLアップデート MySQLの制限 MySQL参加

Python MongoDB

MongoDBはじめに MongoDBデータベースの作成 MongoDBCreateコレクション MongoDBインサート MongoDB検索 MongoDBクエリ MongoDBソート MongoDB削除 MongoDBドロップコレクション MongoDBアップデート MongoDBの制限

Pythonリファレンス

Pythonの概要 Python組み込み関数 Python文字列メソッド Pythonリストメソッド Python辞書メソッド Pythonタプルメソッド Pythonセットメソッド Pythonファイルメソッド Pythonキーワード Pythonの例外 Python用語集

モジュールリファレンス

ランダムモジュール リクエストモジュール 統計モジュール 数学モジュール cMathモジュール

Pythonハウツー

リストの重複を削除する 文字列を逆にする 2つの数字を追加する

Pythonの例

Pythonの例 Pythonコンパイラ Python演習 Pythonクイズ Python証明書

Pythonリクエスト。応答オブジェクト

❮リクエストモジュール


Webページにリクエストを送信し、ステータスコードを返します。

import requests

x = requests.get('https://w3schools.com')
print(x.status_code)

定義と使用法

オブジェクトにはrequests.Response()、HTTPリクエストに対するサーバーの応答が含まれています。


プロパティとメソッド

Property/Method Description
apparent_encoding Returns the apparent encoding
close() Closes the connection to the server
content Returns the content of the response, in bytes
cookies Returns a CookieJar object with the cookies sent back from the server
elapsed Returns a timedelta object with the time elapsed from sending the request to the arrival of the response
encoding Returns the encoding used to decode r.text
headers Returns a dictionary of response headers
history Returns a list of response objects holding the history of request (url)
is_permanent_redirect Returns True if the response is the permanent redirected url, otherwise False
is_redirect Returns True if the response was redirected, otherwise False
iter_content() Iterates over the response
iter_lines() Iterates over the lines of the response
json() Returns a JSON object of the result (if the result was written in JSON format, if not it raises an error)
links Returns the header links
next Returns a PreparedRequest object for the next request in a redirection
ok Returns True if status_code is less than 400, otherwise False
raise_for_status() If an error occur, this method returns a HTTPError object
reason Returns a text corresponding to the status code
request Returns the request object that requested this response
status_code Returns a number that indicates the status (200 is OK, 404 is Not Found)
text Returns the content of the response, in unicode
url Returns the URL of the response

❮リクエストモジュール