Skip to content

Commit 057e4ef

Browse files
Added DOM Extraction Script
1 parent a9f85d5 commit 057e4ef

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

DOM EXTRACTION/main.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
# Define the URL of the website you want to extract the DOM from
5+
url = 'https://www.facebook.com'
6+
7+
response = requests.get(url)
8+
9+
if response.status_code == 200:
10+
soup = BeautifulSoup(response.text, 'html.parser')
11+
12+
13+
title = soup.title
14+
if title:
15+
print("Page Title:", title.text)
16+
else:
17+
print("No title tag found.")
18+
19+
20+
links = soup.find_all('a')
21+
print("Links in the page:")
22+
for link in links:
23+
print(link.get('href'))
24+
25+
else:
26+
print("Failed to retrieve the page. Status code:", response.status_code)

0 commit comments

Comments
 (0)