Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

login to sso.accounts.dowjones.com for wsj.com "python"

import requests
from bs4 import BeautifulSoup
import re
import base64
import json

username="your_email@gmail.com"
password="your_password"
base_url="https://accounts.wsj.com"

session = requests.Session()
r = session.get("{}/login".format(base_url))
soup = BeautifulSoup(r.text, "html.parser")
jscript = [ 
    t.get("src") 
    for t in soup.find_all("script") 
    if t.get("src") is not None and "app-min" in t.get("src")
][0]

credentials_search = re.search("Base64.decode('(.*)'", r.text, re.IGNORECASE)
base64_decoded = base64.b64decode(credentials_search.group(1))
credentials = json.loads(base64_decoded)

print("client_id : {}".format(credentials["clientID"]))
print("state     : {}".format(credentials["internalOptions"]["state"]))
print("nonce     : {}".format(credentials["internalOptions"]["nonce"]))
print("scope     : {}".format(credentials["internalOptions"]["scope"]))

r = session.get("{}{}".format(base_url, jscript))

connection_search = re.search('connection:s*"(w+)"', r.text, re.IGNORECASE)
connection = connection_search.group(1)

r = session.post(
    'https://sso.accounts.dowjones.com/usernamepassword/login',
    data = {
        "username": username,
        "password": password,
        "connection": connection,
        "client_id": credentials["clientID"],
        "state": credentials["internalOptions"]["state"],
        "nonce": credentials["internalOptions"]["nonce"],
        "scope": credentials["internalOptions"]["scope"],
        "tenant": "sso",
        "response_type": "code",
        "protocol": "oauth2",
        "redirect_uri": "https://accounts.wsj.com/auth/sso/login"
    })
soup = BeautifulSoup(r.text, "html.parser")

login_result = dict([ 
    (t.get("name"), t.get("value")) 
    for t in soup.find_all('input') 
    if t.get("name") is not None
])

r = session.post(
    'https://sso.accounts.dowjones.com/login/callback',
    data = login_result)

#check connected user
r = session.get("https://www.wsj.com/articles/singapore-prime-minister-lee-rejects-claims-he-misused-state-powers-in-family-feud-1499094761?tesla=y")
username_search = re.search('"firstName":s*"(w+)",', r.text, re.IGNORECASE)
print("connected user : " + username_search.group(1))
Comment

PREVIOUS NEXT
Code Example
Python :: text to speech free python 
Python :: How to Preprocess for categorical data 
Python :: Visual Studio Code pylint: Error when all is ok 
Python :: python forward declaration 
Python :: Use one function for the "ComboboxSelected", to read multiple combobox 
Python :: city of stars how many words in a song python code 
Python :: python how to convert each word of each row to numeric value of a dataframe 
Python :: pydantic model from dataclass 
Python :: get distance between points in 1 array pythoin 
Python :: python code sample submission of codeforces 
Python :: block-all-mixed-content csp bypass python 
Python :: integration test python 
Python :: How to send an image that was sent with a post request to a model for prediction 
Python :: How to solve import errors while trying to deploy Flask using WSGI on Apache2 
Python :: how to blend pixels in pygame 
Python :: check if id is present in elasticsearch using python 
Python :: get the first principle component of pca 
Python :: ring convert between Numbers and Bytes 
Python :: ring The For Loops uses the local scope 
Python :: ring Desktop, WebAssembly and Mobile Using QTreeView and QFileSystemModel 
Python :: salamelecus 
Python :: dic to dic arrays must all be same length 
Python :: python strip txt 
Python :: separate array along axis 
Python :: python tuple multiply sequence 
Python :: cv2 warpaffine rotate 
Python :: how to kick and ban members with discord.py 
Python :: how to make a instagram report bot python 
Python :: rename column in dataframe 
Python :: Which function is used to write all the characters? 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =