JustCaptain kod-buduschego
987c64ff6f1070f722e2f060dc226970e8af6216
Перейти к файлу
Код
kod-buduschego Python 2025-20264.2. Веб-скрапингpracticestask_3.py
anc update c70a58f 8 октября 2026 г.
task_3.py
import requests
from bs4 import BeautifulSoup

url: str = "https://new-science.ru/"

response = requests.get(url=url)
text: str = response.text

soup = BeautifulSoup(text, "html.parser")
links = soup.find_all("a")
save: str = ""
for index in range(len(links)):
    save = save + str(links[index]) + "\n"
with open("links.txt", mode="w", encoding="utf-8") as file:
    file.write(save)