#!/usr/bin/env python3
# Anchor extraction from HTML document
from bs4 import BeautifulSoup
from urllib.request import urlopen
with urlopen("https://en.wikipedia.org/wiki/Main_Page") as response:
soup = BeautifulSoup(response, "html.parser")
for anchor in soup.find_all("a"):
print(anchor.get("href", "/"))
import requests
from bs4 import BeautifulSoup
url = "https://wikipedia.org"
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
headings = soup.find_all("div")
for heading in headings:
print(heading.text.strip())