When asked what to use it for, there is no choice but to shut up
import requests
import re
import csv
from bs4 import BeautifulSoup
r = requests.get('https://aws.amazon.com/jp/products/')
data = BeautifulSoup(r.text,'html.parser')
tags = data.find_all("div",class_="lb-content-item")
regex = re.compile('<a href.*?>(?P<name>.*?)<span>(?P<content>.*?)</span>')
with open('a.csv','w',newline='',encoding='utf8') as f:
writer = csv.writer(f)
for t in map(lambda tag:str(tag),tags):
m = regex.search(t)
writer.writerow([m['name'],m['content']])
a.csv
Amazon Athena,Data query in S3 using SQL
Amazon CloudSearch,Managed search service
...
Recommended Posts