PythonのSeleniumエラー
PythonでSeleniumを使ってscrapingしているんだけど、
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot activate web view
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: xxx.xxx
が出る。
のサイトどおり、
options.add_argument("--disable-infobars") options.add_argument("--disable-dev-shm-usage") options.add_argument("--disable-browser-side-navigation") options.add_argument("--disable-gpu") options.add_argument("--disable-features=VizDisplayCompositor")
を指定すると改善した。
TerminalからFinderを開く方法
open コマンドを使う
現在いるフォルダをFinderで開くには以下のようにする
open .
curlコマンドでレスポンスヘッダを表示する
curlコマンドでレスポンスヘッダを表示するには、以下の方法。
- --dump-header(-D) オプションを指定する。
- -I オプションを指定する(レスポンスヘッダのみ表示)
--dump-headerには出力先を指定が必要。 -とすれば 標準出力が出力先になる
curl --dump-header - http://www.w3c.org/
Twitter APIで"Client Forbidden"エラー
Tweeter APIを使用したアプリを作成していて、以下のエラーではまった。
When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.
Twitter Developer Potalで表示されるBearer Tokenをつけたcurlコマンドを実行しているのだが、何故かエラーが出る。 Bearer Tokenは、Developer Potalで出力したものを設定しているのに。。。
curl "https://api.twitter.com/2/tweets?ids=1261326399320715264,1278347468690915330" -H "Authorization: Bearer $BearerToken"
あれこれ、ハマった結果、Developer Potalでアプリはあるけど、プロジェクトが紐付けられてなかった。 プロジェクトを作成したら、エラーにならなくなりました。。。
よくみたらエラーメッセージの中に書いてるやん。。。英語を鍛えないとなぁ。
you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.
文字列型を整数型に変換するint関数
num = '10' print(int(num))
キーボードからの入力を取得するinput関数
[Python]キーボードからの入力を取得するinput関数
input_line = input()