Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
スクレイピングの練習 必要なタグを抽出する
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:
#不要なものを空白に置き換える。
word = str(words).replace('<td>', '').replace('</td>', '').replace('<br/>', ':')
f = open('english_words.txt', 'w',encoding='UTF-8')
f.write(word)
f.close()
print(word)
#スクレイピングマナー
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment