Y!mobileに機種変更

自分のじゃないけど

ガラケーからスマホにしたいというので‪Yahoo! BBを解約してdocomoからY!mobileに機種変更

UQ mobileにしたかったけど市内にサポートの店舗がないので却下、Y!mobileは市内にあるのでとりあえずOK

エディオンHUAWEI P10liteがプランM加入で0円だったのでそれにしました。月末にプラン変更予定

ソフトバンクWi-Fiスポットは対応機種リストには載っていませんが普通に使えます。

Y!mobileだと通話は10分無料でメールアドレスも付いてるから低速モードがないのでもったいないけど

徒歩2分のところにEhime Wi-Fiがあるので散歩がてら行ってもらえばプランSでも大丈夫かな

herokuでtwitter botを定時実行

pipenv install python-twitter
pipenv install html5lib
pipenv install beautifulsoup4
pipenv install apscheduler
pipenv install requests

pipenv run pip freeze > requirements.txt
echo "python-3.6.7" > runtime.txt
echo "clock: python clock.py" > Procfile

git config --global user.name "xxxxx"
git config --global user.email "xxxxx@gmail.com"

rm -rf .git

git init
git add .
git commit -m "my first commit"

heroku create xxxxx

git push heroku master

clock.py

from apscheduler.schedulers.blocking import BlockingScheduler
import os

sched = BlockingScheduler()

# 30分毎
# @sched.scheduled_job('interval', minutes=30)
# 1時間毎
# @sched.scheduled_job('interval', hours=1)

# 定時
@sched.scheduled_job('cron', minute=00, hour=7)
def dam_job():

    os.system('python tamagawa-dam.py')


@sched.scheduled_job('cron', minute=30, hour=7)
def hospital_job():

    os.system('python today-hospital.py')

sched.start()
sudo snap install --classic heroku

heroku login -i

heroku git:clone -a xxxxx

git init
git add .
git commit -m "my first commit"
git push heroku master

heroku logout

Pythonでselenium headless(Firefox・Chrome)

Firefox

github.com

sudo cp geckodriver /usr/local/bin
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from bs4 import BeautifulSoup

options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)

driver.get('http://www.yahoo.co.jp')

# ブラウザ操作

driver.save_screenshot("ss.png")

html = driver.page_source
driver.quit()

soup = BeautifulSoup(html, 'html.parser')

Chrome

sites.google.com

from selenium import webdriver
from bs4 import BeautifulSoup

options = webdriver.ChromeOptions()
options.set_headless()
driver = webdriver.Chrome(chrome_options=options)

driver.get('http://www.yahoo.co.jp')

# ブラウザ操作

driver.save_screenshot("ss.png")

html = driver.page_source
driver.quit()

soup = BeautifulSoup(html, 'html.parser')

herokuでheaderless chromeでConnectionResetError 104

3日に1回ぐらいエラーで失敗しているので

Traceback (most recent call last):
  File "today-hospital.py", line 17, in <module>
    driver = webdriver.Chrome(chrome_options=options)
    desired_capabilities=desired_capabilities)
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 310, in execute
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 466, in execute
    response = self.execute(Command.NEW_SESSION, parameters)
    response = self.command_executor.execute(driver_command, params)
    return self._request(command_info[0], url, body=data)
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 490, in _request
    resp = self._conn.getresponse()
    response.begin()
    version, status, reason = self._read_status()
  File "/app/.heroku/python/lib/python3.6/http/client.py", line 258, in _read_status
  File "/app/.heroku/python/lib/python3.6/socket.py", line 586, in readinto
  File "/app/.heroku/python/lib/python3.6/http/client.py", line 1331, in getresponse
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
    return self._sock.recv_into(b)
  File "/app/.heroku/python/lib/python3.6/http/client.py", line 297, in begin
ConnectionResetError: [Errno 104] Connection reset by peer

stackoverflow.com

# 1/30 ウエイトを入れてみたけど再発
driver.implicitly_wait(10)

# 2/2 以下を追加
options.add_argument('--no-sandbox')
driver.set_page_load_timeout(60)

#2/5
Phantomjsに変更

エラーがなくなればいいんだけどだめならPhantomjsに変更しようかな 2/9 Phantomjsに変更してからエラーなし

自作ルーター

qiita.com

internet.watch.impress.co.jp www.sophos.com

作ってみようか悩み中

インフルエンザによる学級閉鎖等の状況

import requests
from bs4 import BeautifulSoup

url = 'http://www.city.imabari.ehime.jp/gakukyou/info_influenza/'
r = requests.get(url)

# エラーがないか確認する

if r.status_code == requests.codes.ok:

    soup = BeautifulSoup(r.content, 'html.parser')

    for i in soup.select('#main_container > div > table > tbody > tr'):
        print('-' * 30)
        print('インフルエンザによる学級閉鎖等の状況(市立小・中学校)')
        print(i.get_text(' ', strip=True))
        print(url)

【解決】カスペルスキー12月のWindows Updateするとエラーメッセージ

以下は10:00以降にカスペルスキーをアップデートした場合は大丈夫そうです

電話で問い合わせしたがどうも殺到しているようで受付のみ 後日メールにて返答あり

カスペルスキーとWindowsDefenderも無効になるので とりあえずカスペルスキーをアンインストールして待機中

10:00過ぎメールに連絡があり

製品の完全削除後の再インストールを行い、改善確認をお願いいたします。 で直りました。

エラーがでる場合

1.最新版ダウンロード

home.kaspersky.co.jp

2.アンインストールツールでアンインストール

http://media.kaspersky.com/utilities/ConsumerUtilities/kavremvr.exe 管理者権限で起動し以下2つをアンインストール

3.インストールフォルダからフォルダ削除 「Program Files」と「Program Files (x86)」と「ProgramData」に 「Kaspersky Lab」または「Kaspersky Lab Setup Files」フォルダが存在する場合削除

4.TEMPフォルダを削除

5.Windows Updateで最新に

6.カスペルスキーのインストール

以上で直りました。