Skip to content

Instantly share code, notes, and snippets.

@project237
Created November 27, 2022 14:42
Show Gist options
  • Save project237/b1d6756849a17812c972a72e53443efb to your computer and use it in GitHub Desktop.
Save project237/b1d6756849a17812c972a72e53443efb to your computer and use it in GitHub Desktop.
temp1
from bs4 import BeautifulSoup
import requests
from pprint import pprint
import time
from cnd_login import KEY, USERNAME, COOKIE, HEADERS
BASE_URL = "edge.cindicator.com"
TARGET_URL = "https://edge.cindicator.com/indicators"
LOGIN_URL = "https://edge.cindicator.com/login"
OUTPUT_FILENAME = "cnd_indicators.html"
PAYLOAD = {
"email" : USERNAME,
"password" : KEY
}
print()
r = None
# with requests.session() as s:
# r = s.get(TARGET_URL, cookies=COOKIE)
# print("Status Code: ", r.status_code)
# print(r.url)
with requests.session() as s:
login = s.post(LOGIN_URL, data=PAYLOAD)
# login = s.post(LOGIN_URL, data=PAYLOAD, headers=HEADERS, cookies=COOKIE)
# time.sleep(3)
pprint(login.cookies)
print(type(login.cookies))
r = s.get(TARGET_URL, cookies=login.cookies)
# r = s.get(TARGET_URL)
print("Status Code: ", login.status_code)
print(r.url)
# print(login.text)
# soup = BeautifulSoup(r.content, "html.parser")
# print(soup.prettify())
# save r html content into OUTPUT_FILENAME
with open(OUTPUT_FILENAME, "w") as f:
f.write(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment