大学のホームページをランダムに表示する
製造中
完了
ソースはWikipedia
code:s.py
import requests
from bs4 import BeautifulSoup
daigaku = open("d.txt","r").readlines()
for d in daigaku:
try:
d=d.replace("\n","")
html_doc = requests.get(
soup = BeautifulSoup(html_doc, 'html.parser')
real_page_tags = soup.find_all("a", attrs={"class", "external free"})
ou = real_page_tags0.get("href")+","+d print(ou)
with open("a", 'a') as f:
f.write(ou+"\n")
except IndexError:
print(d)
with open("a", 'a') as f:
f.write(d+"\n")
おもしろいですね
U.icon