-
BeautifulSoupで不要な文字列を削除する(decompose)
Python
<h2>wanted<span class="aaa">www</span></h2> h2 = soup.find('h2') span = soup.find('span') span.decompose() print(h2.text) // wanted h2 = soup.find('h2').text span = soup.find('span') span.decompose() print(h2) // wanted www -
【Python】requestのヘッダーを設定する
Python
headers = { 'aaa': 'bbb', 'ccc': 'ddd' } response = requests.get(url, header) -
Scrapyのコマンド
Scrapy
scrapy // ターミナルで実行 Scrapy 2.11.1 - active project: splash_project Usage: scrapy <command> [options] [args] Available commands: bench Run quick benchmark test check Check spider contracts crawl Run a spider edit Edit... -
Macのコマンド
Mac
option + ¥ // バックスラッシュ「\」 -
【SourceTree】追跡を止める
Git
ファイルステータスから追跡をやめたいクリックを右クリック 追跡を止めるを選択 コミット .gitignoreに追記 -
【SourceTree】.gitignoreファイルを設定
Git
右上の設定アイコン 高度な設定 リポジトリ限定無視リスト -
【Git】バージョン管理が不要なファイルを無視する
Git
.gitignore xxx.html // 特定のファイルを無視 *.html // 特定の拡張子を無視 !xxx.html // 例外(無視をしない) dr/ // drディレクトリ以下を無視 /dr/ // ルートディレクトリから指定 # // コメント -
Live Sass Compilerで出力先を変更する
Visual Studio Code
settings.json "liveSassCompile.settings.formats": [ { "format": "expanded", "extensionName": ".css", "savePath": "./assets/css", "savePathReplacementPairs": null } ] -
相対パス
Apache
/xxx // ルートディレクトリからのパス xxx // 現在のディレクトリからのパス ./xxx // 現在 ../xxx // 1つ上の階層 ~ // ホームディレクトリ -
PHPでデータベースからデータを取得した際の返り値
PHP
$pdo = new PDO($dsn, $user, $pwd); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $pst = $pdo->query('select * from table_name'); // $result = $pst->fetchALL(PDO::FETCH_ASSOC); $result = $pst->fetchALL(); echo ('<...