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 c643b6f

Browse files
authored
Merge pull request #354 from Yolo-cell-hash/dom-branch
DOM Extraction Script add
2 parents 3eb3ae4 + 3e67747 commit c643b6f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

‎DOM EXTRACTION/README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# DOM Extraction Script
2+
3+
Extract the DOM elements of a webpage efficiently.
4+
5+
## Installation
6+
7+
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install the required libraries.
8+
9+
```bash
10+
pip install requests beautifulsoup4
11+
12+
```
13+
14+
## Usage
15+
16+
```python
17+
url = 'https://example.com'
18+
```
19+
Replace 'https://example.com' with the URL of the website you want to extract the DOM from.

‎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://example.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 によって変換されたページ (->オリジナル) /