-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add function for getting page content and unit test for it
- Loading branch information
vlaszdunov
committed
Jun 4, 2024
1 parent
ec46770
commit da2eea6
Showing
7 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
#byte-compiled | ||
__pycache__ | ||
|
||
# Environment | ||
.venv | ||
.env | ||
|
||
# ide-staff | ||
.vscode |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import requests | ||
from bs4 import BeautifulSoup as bs | ||
|
||
BASE_URL = 'https://www.python.org/' | ||
headers = json.loads(Path('src/request_header.json').read_bytes()) | ||
|
||
|
||
def get_page_content(internal_page: str = '') -> bs: | ||
page_content = requests.get(BASE_URL+internal_page, headers=headers).text | ||
return bs(page_content, 'lxml') | ||
|
||
|
||
def get_active_versions(versions_page_internal_url: str): | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
from src.version_parser import * | ||
|
||
BASE_URL = 'https://www.python.org/' | ||
|
||
|
||
def test_get_page_content(): | ||
page_content = get_page_content(BASE_URL) | ||
assert len(page_content.contents) != 0 |