Skip to content

Instantly share code, notes, and snippets.

@obafgkm44
obafgkm44 / html_scraping.py
Last active March 28, 2019 05:02
スクレイピングの練習 htmlを表示する
import requests
response = requests.get('https://toiguru.jp/toeic-vocabulary-list#smoothplay1')
print(response.text)
@obafgkm44
obafgkm44 / english_words_scraping.py
Last active March 28, 2019 09:16
スクレイピングの練習 必要なタグを抽出する
import requests
import time
from bs4 import BeautifulSoup
response = requests.get('https://toiguru.jp/toeic-vocabulary-list#smoothplay1')
soup = BeautifulSoup(response.text,'lxml')
words = soup.findAll('td')
for word in words:
@obafgkm44
obafgkm44 / img_getter.py
Last active March 31, 2019 17:10
画像のダウンロードとその画像を画面に表示させる
# 画像のダウンロード
import urllib.request as req
url = "https://amd.c.yimg.jp/amd/20190331-00000059-asahi-000-2-view.jpg"
req.urlretrieve(url,"sakura.jpg")
# ダウンロードした画像を画面に表示する
import matplotlib.pyplot as plt
import cv2
# 画像を読み込む
img = cv2.imread("sakura.jpg")
@obafgkm44
obafgkm44 / img_resize.py
Last active March 31, 2019 17:12
画像を切り取る
# ダウンロードした画像を画面に表示する
import matplotlib.pyplot as plt
import cv2
# 画像を読み込む
img = cv2.imread("sakura.jpg")
#一部を切り取り
im = img[100:300,100:300]
@obafgkm44
obafgkm44 / roots_getter.py
Created April 3, 2019 18:43
スクレイピングーー語源で英単語を増やす
import requests
from bs4 import BeautifulSoup as bs4
#<td>のタグを抽出する
r = requests.get('http://gogengo.me/roots')
data = bs4(r.text,'html.parser')
elems = data.findAll("td")
#テキストを画面に出力する
for e in elems:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.