outlook.comのメアドで勝手にfacebookに登録された。
今回で2回目、facebookに連絡して凍結してもらったが対策方法を聞くと
アカウントを登録するか、既存のFacebookアカウントにこのメールアドレスを追加するしかないとのこと。
既存のFacebookアカウントに登録したら身バレするので新規にアカウントを登録したけど対策がないのかな
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
年末ぐらいから貯水率が表示されていない。
https://maps.google.comで住所を入力して共有をクリック
地図を埋め込むを選びコピペ
<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 に貼り付ける。
表示サイズに合わせてサイズ調整してくれます。
日付 | 時間 | 内容 |
---|---|---|
12/1 | 7:00 | 1・2申込 |
12/1 | 12:00 | 2審査終了 |
12/1 | 14:00 | 1審査終了 |
12/2 | 発送 | |
12/5 | 到着 |
また新しいお題がでていたので
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)
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)
指定のセルに毎回入力するのがめんどくさいので Pythonのopenpyxlで作ったら線が崩れるので別の方法を探していたところ Powershellからだと崩れずきれいに入力できた
$excel = New-Object -ComObject Excel.Application $excel.Visible = $false $book = $excel.Workbooks.Open($args[0]) $sheet = $book.Sheets("Sheet1") Import-Csv 'test.tsv' -Delimiter "`t" | ForEach-Object { $sheet.Range($_.cell) = $_.data } # 上書き保存 $book.Save() # Excelを閉じる $excel.Quit() # プロセスを解放する $excel = $null [GC]::Collect()
セルのアドレス 書き込みデーターのTSVファイル作成
cell data A1 あいうえお B2 かきくけこ B3 さしすせそ
そのままでは実行できないのでバッチファイル作成
@echo off chcp 65001 echo EXCELに書き込みします… powershell -NoProfile -ExecutionPolicy Unrestricted .\powershell.ps1 %1 echo 完了しました! pause > nul exit