Pycharmをインストール

インストール

sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make

sudo apt-get update && sudo apt-get install ubuntu-make

umake ide pycharm

アップデート

umake ide pycharm -r && umake ide pycharm

umakeはアップデートないので消してからインストール

フォント

https://github.com/adobe-fonts/source-han-code-jp

初期設定

www.task-notes.com

  • Editor
    • General
      • Appearance

Show line numbers - ON
Show method separators - ON
Show whitespaces - ON

f:id:imabari_ehime:20170107212924p:plain

qiita.com

仮想化

プロジェクト作成時に歯車を押して「Create Conda ENV」を選択し、名前を「py35」で作成

source activate py35

conda install anaconda

deactivate

imabari.hateblo.jp

Facebookに勝手に登録

outlook.comのメアドで勝手にfacebookに登録された。

今回で2回目、facebookに連絡して凍結してもらったが対策方法を聞くと

アカウントを登録するか、既存のFacebookアカウントにこのメールアドレスを追加するしかないとのこと。

既存のFacebookアカウントに登録したら身バレするので新規にアカウントを登録したけど対策がないのかな

Windows10アップデートすると再起動後使用不能

ToshibaのノートパソコンがWindowsアップデート後起動不能になる原因がやっとわかった

症状はWindowsアップデート後再起動されるとグルグル回るところで止まってしまう 電源長押しでもシャットダウンできなくてバッテリーを抜いて電源を落として起動すると普通に動く。 何カ月も悩んだ結果ロジクールの無線キーボードK270と無線マウスM525のUSBレシーバーが原因だった。 USBレシーバーを抜くとログイン画面が表示された。

早明浦ダムの貯水率をスクレイピング

qiita.com

d.hatena.ne.jp

from urllib.request import urlopen
from bs4 import BeautifulSoup

base = 'http://www1.river.go.jp'

resp = urlopen(base + '/cgi-bin/DspDamData.exe?ID=1368080700010&KIND=3').read()
temp = BeautifulSoup(resp, 'html5lib')

# IFRAMEのURLからデータ取得
html = urlopen(base + temp.iframe['src']).read()
soup = BeautifulSoup(html, 'html5lib')

for tr in soup.select('tr'):
    tds = [td.string.strip() for td in tr.select('td')]

    if tds[6] != '-':
        print('早明浦ダムの{} {}現在の貯水率は{}%です'.format(tds[0], tds[1], tds[6]))
        break

2017/01/07

年末ぐらいから貯水率が表示されていない。

Google Mapをレスポンシブ対応

https://maps.google.comで住所を入力して共有をクリック

f:id:imabari_ehime:20161204132132p:plain

地図を埋め込むを選びコピペ

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3305.2039123020745!2d132.991596815661!3d34.0642866806027!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x35503a596c798ac9%3A0x45214b6b3b8d4fd4!2z5LuK5rK76aeF!5e0!3m2!1sja!2sjp!4v1480824900439" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

width="600"のところをwidth="100%"に変更

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3305.2039123020745!2d132.991596815661!3d34.0642866806027!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x35503a596c798ac9%3A0x45214b6b3b8d4fd4!2z5LuK5rK76aeF!5e0!3m2!1sja!2sjp!4v1480824900439" width="100%" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

上のコードを HTML に貼り付ける。

表示サイズに合わせてサイズ調整してくれます。

netkeibaのスクレイピング2

また新しいお題がでていたので

ja.stackoverflow.com ja.stackoverflow.com

from urllib.request import urlopen
from bs4 import BeautifulSoup
import csv

url = 'http://race.netkeiba.com/?pid=race&id=c201605050211&mode=shutuba'
html = urlopen(url).read()

soup = BeautifulSoup(html, 'html5lib')

tr = soup.select('#shutuba > table > tbody > tr')


# 改行ごとに分解、前後の空白文字を除去、空行なら除外し、結合

# td = [['\n'.join([z.strip() for z in x.get_text().splitlines() if z.strip()]) for x in y.find_all(['th', 'td'])] for y in tr]

td = [[x.get_text("\n", True) for x in y.find_all(['th', 'td'])] for y in tr]

with open('race.csv', 'wt', encoding='utf-8') as fw:
    writer = csv.writer(fw, lineterminator='\n')
    writer.writerows(td)

ja.stackoverflow.com

from urllib.request import urlopen
from bs4 import BeautifulSoup
import csv

url = 'http://race.netkeiba.com/?pid=race&id=c201605050211&mode=shutuba'
html = urlopen(url).read()

soup = BeautifulSoup(html, 'html5lib')

with open('name.csv', 'wt', encoding='utf-8') as fw:
    writer = csv.writer(fw, lineterminator='\n')

    for tr in soup.select('#shutuba > table > tbody > tr')[1:]:

        td = tr.select_one('td:nth-of-type(7)')
        # td = tr.select('td')[6]

        names = []
        names.append(td.select_one('span.h_name > a').get_text().strip())
        names.extend([i.strip('()') for i in td.select_one('span.txt_smaller').get_text().split()])

        writer.writerow(names)

imabari.hateblo.jp