Pythonプログラミングの講義23日目。
人工無脳は、いよいよインターネットアクセス。
定番の、requestsとbs4となります。
【講義内容】
- Chapter8 インターネットアクセス
【ワンポイント】
BeautifulSoup
pip install beautifulsoup4
import requests from bs4 import BeautifulSoup url = 'https://news.yahoo.co.jp/rss/topics/it.xml' xml = requests.get(url) soup = BeautifulSoup(xml.text, 'html.parser') for news in soup.findAll('item'): print(news.title.string) print(news.description.string) print(news.comments.string)
【今日の積み上げ】
- Python基礎