初日に登録し、毎日学んだ小さな知識を記録します.
1947 ワード
毎日学んだ小さな知識を記録する計画です.そうしましょう.
matlab:
ロード方法matファイルをマトリクス形式に変換
Mymat 1はマトリクス形式(S 1はStruct Array形式)です.
爬虫類:
r.status_code#レスポンスステータスコード
r.raw#は元の応答体、すなわちurllibのresponseオブジェクトを返し、r.rawを用いる.read()読み出し
r.content#バイト方式の応答体は、gzipとdeflate圧縮を自動的に復号します.
r.text#文字列方式の応答体は、応答ヘッダの文字符号化に基づいて自動的に復号される
r.headers#はディクショナリオブジェクトでサーバ応答ヘッダを格納するが、このディクショナリは比較的特殊で、ディクショナリキーは大文字と小文字を区別せず、キーが存在しない場合はNoneを返す
特別な方法#
r.json()#Requestsに内蔵されたJSONデコーダ
r.raise_for_status()#失敗要求(200以外の応答)放出異常
よく使われるheaders
matlab:
ロード方法matファイルをマトリクス形式に変換
S1 = load('IntBP1.mat');
BP1 = struct2cell(S1);
Mymat1 = cell2mat(BP1);
save Mymat1.mat Mymat1 -MAT
Mymat 1はマトリクス形式(S 1はStruct Array形式)です.
cell:
cellfun:
celldisp:
cellplot:
cell2mat:
mat2cell:
num2cell:
deal:
cell2struct:
struct2cell:
iscell:
爬虫類:
, , , Network , requests,bs4,json ; , , Element , requests,bs4 。
requests.get json() response / , 。
requests , response , text , content , , 。
r.status_code#レスポンスステータスコード
r.raw#は元の応答体、すなわちurllibのresponseオブジェクトを返し、r.rawを用いる.read()読み出し
r.content#バイト方式の応答体は、gzipとdeflate圧縮を自動的に復号します.
r.text#文字列方式の応答体は、応答ヘッダの文字符号化に基づいて自動的に復号される
r.headers#はディクショナリオブジェクトでサーバ応答ヘッダを格納するが、このディクショナリは比較的特殊で、ディクショナリキーは大文字と小文字を区別せず、キーが存在しない場合はNoneを返す
特別な方法#
r.json()#Requestsに内蔵されたJSONデコーダ
r.raise_for_status()#失敗要求(200以外の応答)放出異常
bs4.BeautifulSoup requests.get , .text print , ,
import requests
from bs4 import BeautifulSoup
# BS
res = requests.get('https://localprod.pandateacher.com/python-manuscript/crawler-html/spider-men5.0.html')
html = res.text
soup = BeautifulSoup(html,'html.parser') # BeautifulSoup ,BeautifulSoup 0 , 1
よく使われるheaders
headers={'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'}
res=requests.get(url,headers=headers)