Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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‎

Lines changed: 26 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /