NPCA部誌2018

Similar documents
NPCA部誌2018

デュアルウェア講習会課題 5 会津大学講習会 簡単な IoT を作成 2018 The University of Aizu

161 Debian.Deb 銀河系唯一の Debian 専門誌 GO

ii II Web Web HTML CSS PHP MySQL Web Web CSS JavaScript Web SQL Web

2

RSS Dripper [1] Whazzup [2] Summ

Wiki

manual.dvi

ご利用のコンピュータを設定する方法 このラボの作業を行うには 事前設定された dcloud ラボを使用するか 自身のコンピュータをセットアップします 詳細については イベントの事前準備 [ 英語 ] とラボの設定 [ 英語 ] の両方のモジュールを参照してください Python を使用した Spar

1 Linux UNIX-PC LAN. UNIX. LAN. UNIX. 1.1 UNIX LAN. 1.2 Linux PC Linux. 1.3 studenta odd kumabari studentb even kumabari studentc odd kumabari student

2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa

常時接続可能な APIC-EM ラボの DevNet Sandbox は次の URL から利用できます : SSL 証明書を必ず受け入れるようにしてください Git Repo を複製する o コーディングスキルのサンプルコードを複製します

PYTHON 資料 電脳梁山泊烏賊塾 PYTHON 入門 ゲームプログラミング スプライトの衝突判定 スプライトの衝突判定 スプライトの衝突判定の例として インベーダーゲームのコードを 下記に示す PYTHON3 #coding: utf-8 import pygame from pygame.lo

大統一Debian勉強会 gdb+python拡張を使ったデバッグ手法

Rによる計量分析:データ解析と可視化 - 第2回 セットアップ

lifedesign_contest_No3

ウェブサービスとは WWWを介してデータの取得 解析などをサー バ側で行うサービス 人が直接使うことは意図されていない プログラム等を使って大量に処理できる(単純) 作業を意図している SOAP, REST

HTML5無料セミナ.key

ohp.mgp

Google Apps for Business Google Gmail Google Apps Google Apps Google Apps 2

Microsoft Word - SNSで繋がる人間関係.doc

In [5]: soup.tbody Out[5]: <tbody> <tr> <th><label for=""> </label></th> <td> </td> <td><input checked="checked" class="input-label-horizontal" id="se

Stapy_Tsuji_ key

Twitter,.,,...,.,.,.,.,,.,.. SNS. SNS,,. SNS,.,,, WordNet,, i

Lightweight LanguageのIPv6対応PHP5編

SMTP FP Mail MX /

_KAIT.pptx

/var/lib/sharelatex/data/compiles/5a535643d11f6ba07fbbfa d68ddec3e /output.dvi

3 Powered by mod_perl, Apache & MySQL use Item; my $item = Item->new( id => 1, name => ' ', price => 1200,

(C) 2011 amenbo the 3rd MQL4 と外部アプリの連携 ;( その2) 本編 amenbo the 3rd アメンボです 前回 ( その1) に続いて 外部アプリとの連携を取り上げます 本稿では MQL4 から Twitter 情報の活用を可能にするための

IoT


スライド 1

Python2 Python3 Python 2.7 Python 3.6 Python2 Python3 Python 2.7 Python3.6 Python Python Anaconda Python Anaconda Python


Web±ÜÍ÷¤Î³Ú¤·¤µ¤ò¹â¤á¤ëWeb¥Ú¡¼¥¸²ÄÄ°²½¥·¥¹¥Æ¥à

25 About what prevent spoofing of misusing a session information

untitled

test

たのしいプログラミング Pythonではじめよう!

WCAN

lucene-gosen Solr1

08+11Extra

XMLアクセス機能説明書

Lotus Domino XML活用の基礎!

名称未設定

オンラインテスト

bash on Ubuntu on Windows bash on Ubuntu on Windows bash on Ubuntu on Windows bash on Ubuntu on Windows bash on Ubuntu on Windows ˆ Windows10 64bit Wi

10 (1) s 10.2 rails c Rails 7 > item = PlanItem.new => #<PlanItem id nil, name nil,...> > item.name = "" => "" > item.valid? => true valid? true false

version 1.0 November 2010 PyRAF Y. Nakajima Computer and Data Management Division Subaru Telescope NAOJ

¥Í¥Ã¥È¥ï¡¼¥¯¥×¥í¥°¥é¥ß¥ó¥°ÆÃÏÀ

Logitec NAS シリーズ ソフトウェアマニュアル

Web XXX.XXX.XXX.XXX - - [02/May/2010:12:52: ] "GET /url/url2/page2.htm HTTP/1.1" " "(compatibl

5. sendmail.cf

9 rbenv rbenv ruby 9.1 rbenv rbenv rbenv ruby ruby-build ruby 9.2 rbenv macos.bash_profile ~/.bash_profile ~/.bash_profile.bak $ touch ~/.bash_profile

Microsoft Word - USB60F_Raspi_ doc

RR-US470 (RQCA1588).indd

IT講習会

Python (Anaconda ) Anaconda 2 3 Python Python IDLE Python NumPy 6

JTS Google App Engine S119325

1,.,,,., RDBM, SQL. OSS,, SQL,,.

A : kerl kerl Erlang/OTP Erlang/OTP 2 2 Elixir/Phoenix URL 2 PDF A.2 Bash macos.bash_profile exp

untitled

Mail_Spam_Manual_120815b

s

JavaScript の使い方

Microsoft Word - 09ビジアプ_2_11_0617.docx


付加情報をもったファイル共有システム

…l…b…g…‘†[…N…v…“…O…›…~…fi…OfiÁŸ_

( ) Shift JIS ( ) ASCII ASCII ( ) 8bit = 1 Byte JIS(Japan Industrial Standard) X 0201 (X ) 2 Byte JIS ISO-2022-JP, Shift JIS, EUC 1 Byte 2 By

FileMaker Server 16 インストールおよび構成ガイド

Logitec NAS シリーズ ソフトウェアマニュアル

FrontSystem FrontSystem

-1-

Ansible

インストール取扱説明書

OSSTechドキュメント

情報システム設計論II ユーザインタフェース(1)

エラー処理・分割コンパイル・コマンドライン引数

2008


勉強会の流れ Google API の概要 デモ curl で実際に体験 Copyright 2010 SRA OSS, Inc. Japan All rights reserved. 2

FileMaker Server 8 Advanced Web Publishing Installation Guide

̤Äê

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

retool_ _intro.indd

guide.PDF

my life design portrait file Good Time portrait file

"CAS を利用した Single Sign On 環境の構築"

FileMaker Server Getting Started Guide

Add-onアプリケーション開発 - 環境構築マニュアル -


1 SQL Server SQL Oracle SQL SQL* Plus PL/SQL 2 SQL Server SQL Server SQL Oracle SQL SQL*Plus SQL Server GUI 1-1 osql 1-1 Transact- SQL SELECTFROM 058

MUA (Mail User Agent) MTA (Mail Transfer Agent) DNS (Domain Name System) DNS MUA MTA MTA MUA MB mailbox MB

愛知工業大学表1-4.indd

CAS Yale Open Source software Authentication Authorization (nu-cas) Backend Database Authentication Authorization Powered by A

untitled

Microsoft Word - DoSPOT_UserTool利用マニュアル.doc

Cisco® ASA シリーズルーター向けDigiCert® 統合ガイド

Transcription:

5 72 5.1 72 1.5 (?) (?) Python ( ) ( ) Python : Python import 5.2 Python Python Anaconda https://www.anaconda.com/download/ Anaconda 2 3 (Python2 ) macos Linux,Windows Subsystem for Linux Linux 46

5.3 Python sudo apt-get install python3 python3-pip pip Python macos Homebrew macos Homebrew /usr/bin/ruby -e "$(curl -fssl https://raw.githubusercontent.com/homebrew/install/master/install)" Python brew install python3 5.3 Python Python Python3 Python ( ) python( python3) Helloworld.py print( Hello,world! ) 47

5.4 C:\Users\taizo>python Helloworld.py Hello,world! 5.4 os Python FindFile.py 1 #! python3 2 # -*- coding: utf-8 -*- 3 4 import os 5 import sys 6 7 folder = sys.argv[1] 8 extension = sys.argv[2] 9 #folder extension 10 for foldername, subfolders, filenames in os.walk(folder): 11 for filename in filenames: 12 if filename.lower().endswith(extension):# extension 13 print(os.path.join(foldername, filename))# 2 Python sys sys import sys.argv 1 import sys 2 for i in sys.argv: 3 print(i) argv.py C:\Users\taizo>python argv.py a b c argv.py a b c sys.argv os.walk for 3 os.path.join OS 12~13 os.walk extension( extension) lower 48

C jpg python (FindFile.py ) C:// jpg : C:\Users C:\Users npca.png npca.png c:\users\npca.png Web & Web (Crawling) (Scraping) Google https://tenki.jp 1 #! python3 2 # -*- coding: utf-8 -*- 3 4 import requests 5 import bs4 6 import smtplib 7 from email.mime.text import MIMEText 8 from email.header import Header 9 10 percent = 70 # percent 11 12 url = requests.get( https://tenki.jp/forecast/6/31/6310/28100/ ) # url URL 13 parse = bs4.beautifulsoup(url.text, "lxml") # parse url lxml HTML 14 probability = parse.select(.rain-probability )[0] 15 if int(probability.select( td )[1].text[0]) >= percent or int(probability.select( td )[2].text[0]) >= percent: 16 letter = 17 else: 18 letter = 19 20 charset = iso-2022-jp 21 message = MIMEText(letter, plain, charset) 22 message[ Subject ] = Header(.encode(charset), charset) 23 smtp_obj = smtplib.smtp( smtp.gmail.com, 587) 24 smtp_obj.ehlo() 25 smtp_obj.starttls() 26 smtp_obj.login( FROM, PASSWORD ) 27 smtp_obj.sendmail( FROM, TO, message.as_string()) 49

28 smtp_obj.quit() 12~15 HTML 20~28 requests web requests.get URL bs4 bs4 BeautifulSoup4 BeautifulSoup4 HTML bs4.beautifulsoup HTML ( ) lxml HTML (pip install lxml ) smtplib SMTP(Simple Mail Transfer Protocol) smtplib.smtp smpt Gmail smtp TLS 587 smtplib.ehlo smtp_obj.starttls smtp_obj.quit TLS smtp_obj.login Google https://support.google.com/accounts/answer/185833 smtp_obj.sendmail FROM TO MIMEText Header as_string MIMEText Header 12~15 HTML tenki.jp 50

: tenki.jp ( Ctrl+U ) rain-probability select (. ) : tenki.jp 51

rain-probability 2 1 4 td 2 3 td % 2 (6~12 12~18 ) percent 7 Windows.py.py @(python.exe ) ( ) %* OK API API(Application Programming Interface) (Wikipedia ) API Twitter YouTube Twitter API Twitter Twitter SNS API URL https://developer.twitter.com/ Twitter API Twitter API Twitter (https://apps.twitter.com/) Create New App Callback URL Keys and Access Tokens Create my access token 1 #!python3 2 # -*- coding: utf-8 -*- 3 from requests_oauthlib import OAuth1Session 4 import os 5 import time 6 import shelve 7 import requests 8 9 file = shelve.open( lasttweet ) 10 lasttweet = file[ lasttweet ] # 11 12 CONSUMER_KEY = os.environ[ KEY ] 13 CONSUMER_SECRET = os.environ[ SECRET ] 14 ACCESS_TOKEN = os.environ[ ACCESS_TOKEN ] 15 ACCESS_TOKEN_SECRET = os.environ[ ACCESS_TOKEN_SECRET ] 16 17 twitter = OAuth1Session(CONSUMER_KEY, 18 client_secret=consumer_secret, 19 resource_owner_key=access_token, 20 resource_owner_secret=access_token_secret) 52

21 22 response = twitter.get( https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=@@@@@&since_id= + lasttweet + &count=300& exclude_replies=true&include_rts=false ) 23 24 for tweet in response.json(): 25 try: 26 for image in tweet[ extended_entities ][ media ]: 27 image_url = image[ media_url ] 28 print(image_url) 29 image = requests.get(image_url) 30 image.raise_for_status() 31 image_file = open(os.path.join(, os.path.basename(image_url)), wb ) 32 for chunk in image.iter_content(100000): 33 image_file.write(chunk) 34 image_file.close() 35 time.sleep(5) 36 except: 37 pass 38 39 file.close() Twitter 22 24~37 from requests_oauthlib import OAuth1Session Twitter API OAuth OAuth shelve shelve shelve Python ID lasttweet open close lasttweet import shelve file = shelve.open( lasttweet ) file[ lasttweet ] = file.close() Twitter os.environ 22 22 json 5.1 screen_name since_id count exclude_replies include_rts (@ ) ID true false 24~37 try~except try except try 53

json URL extended_entities media media_url 29~34 raise_for_status 31=33 100000 5 ( ) 54

YouTube API YouTube Google API URL https://developers.google.com/youtube/v3/?hl=ja/ YouTube API YouTubeAPI Google API Console(https://console.developers.google.com) API YouTube Data API v3 API YouTube https://www.youtube.com/account_privacy 1 from apiclient.discovery import build 2 import webbrowser 3 import datetime 4 import shelve 5 import os 6 7 file = shelve.open( begintime ) 8 begindate = datetime.datetime(int(file[ year ]), int(file[ month ]), int(file[ day ]), nt(file[ hour ]), int(file[ minute ]), int(file[ second ])) 9 nowdate = datetime.datetime.now() 10 11 youtube = build( youtube, v3,developerkey=os.environ[ GOOGLE_KEY ]) 12 search = youtube.subscriptions().list(part= snippet, channelid= ID ).execute() 13 14 def getchannel(info): 15 for channel in info[ items ]: 16 getmovie(channel[ snippet ][ resourceid ][ channelid ]) 17 if( nextpagetoken in info.keys()): 18 nextpage = youtube.subscriptions().list(part= snippet, channelid= ID, pagetoken = info[ nextpagetoken ]).execute() 19 channelname(nextpage) 20 21 def getmovie(info): 22 channel = youtube.channels().list(part= contentdetails, id=info).execute() 23 uploads = youtube.playlistitems().list(part= snippet, playlistid=channel[ items ][0][ contentdetails ][ relatedplaylists ][ uploads ], maxresults=50).execute() 24 for movie in uploads[ items ]: 25 moviedate = datetime.datetime.strptime(movie[ snippet ][ publishedat ], %Y-%m-%dT%H:%M:%S.000Z ) 26 moviedate += datetime.timedelta(hours=9) 27 if moviedate > begindate: 28 webbrowser.open( https://www.youtube.com/watch?v= + movie[ snippet ][ resourceid ][ videoid ]) 29 30 getchannel(search) 31 32 file[ year ] = nowdate.year 33 file[ month ] = nowdate.month 34 file[ day ] = nowdate.day 35 file[ hour ] = nowdate.hour 36 file[ minute ] = nowdate.minute 37 file[ second ] = nowdate.second 38 39 file.close() from apiclient.discovery import build Python Google API Client for Python Google API pip install google-api-python-client webbrowser URL 55

datetime datetime datetime year month day hour minute second microsecond shelve shelve YouTube API YouTube API 10 build API API subscriptions().list part channelid ID (YouTube URL https://www.youtube.com/channel/ ID channel ) execute() json getchannel URL subscriptions().list items 1 5 6 nextpagetoken subscriptions().list pagetoken 2 ID getmovie getmovie channels.list() part id ID items contentdetails relatedplaylists uploads ID playlistitems().list part playlistid ID maxresults 1 items snippet publishedat 56

5.6 (2018-04-28T10:51:56.000Z) datetime datetime strptime datetime 9 9 shelve (?)! : ( ) 5.6 Web 57

5.7 5.7 Al Sweigart (2017) Python (2016) Python Twitter API https://developer.twitter.com/ YouTube API https://developers.google.com/youtube/v3/?hl=ja/ 58