Skip to content
Snippets Groups Projects
Commit 89d74244 authored by magnus2142's avatar magnus2142
Browse files

added helper methods for handling cookies, headers and converting html to text

parent 8aa1df9c
No related branches found
No related tags found
No related merge requests found
from datetime import datetime
from typing import Dict, List
from requests import Session
import html2text
def check_valid_key(obj, key) -> bool:
# print("the keys are", obj.keys())
......@@ -31,3 +35,16 @@ def check_valid_date(cookies) -> bool:
return False
def set_cookies(session: Session, cookies: List):
for cookie in cookies:
session.cookies.set(cookie['name'], cookie['value'])
def set_headers(session: Session, headers: List):
for header in headers:
session.headers.update(header)
def html_to_text(html_data: str):
to_text = html2text.HTML2Text()
return to_text.handle(html_data)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment