##問題
pythonのbeautifulsoupで為替相場を取得したいのですが、うまくいきません。
原因は、ページの読み込み後、価格の表示までに若干のタイムラグがあるから(?)だと思うのですが、どのようにすれば治るでしょうか?
##コード
python
1 2# -*- coding: utf-8 -*- 3from bs4 import BeautifulSoup 4import urllib3 5url = "https://info.finance.yahoo.co.jp/fx/detail/?code=USDJPY=FX1" 6# urllib3を使うならこっち 7http = urllib3.PoolManager() 8r = http.request('GET', url) 9 10soup = BeautifulSoup(r.data, 'html.parser') 11data=soup.find(id="USDJPY_detail_bid") 12 13print(data)
##出力
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is str ongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning) <dd id="USDJPY_detail_bid">.<span class="large"></span></dd>
本来なら、
<dd id="USDJPY_detail_bid">**112.**<span class="large">**68**</span>**2**</dd> と表示されるはずなのですが・・・##該当する要素(開発者ツールより)
<dl> <dt>Bid(売値)</dt> <dd id="USDJPY_detail_bid"> 112.<span class="large">68</span>2 </dd> </dl>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/29 23:11