Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Screener Functionality with Finviz Elite Account #41

Open
NimaMPH opened this issue Apr 17, 2020 · 4 comments
Open

Using Screener Functionality with Finviz Elite Account #41

NimaMPH opened this issue Apr 17, 2020 · 4 comments

Comments

@NimaMPH
Copy link

NimaMPH commented Apr 17, 2020

Hi There,

How can I use screener with Finvize Elite account (similar to portfolio) to receive real-time data instead of delayed data?

Thanks,

Nima

@NathanHRich
Copy link

I figured out how to obtain a cookie. But it does something weird to the scraper when you use it. My guess is because it's a different url. https://elite.finviz.com/screener.ashx rather than https://finviz.com/screener.ashx
Here's my quick code to get the cookie header. That's as far as I got for now, I may come back later and work on this more.

def get_auth_header():
    login_url = 'https://finviz.com/login_submit.ashx'
    data = {
        'email': os.environ['FINVIZ_USERNAME'],
        'password': os.environ['FINVIZ_PASSWORD']
    }
    response = requests.post(url=login_url, data=data)
    for history in response.history:
        if history.cookies:
            for c in history.cookies:
                if c.name == '.ASPXAUTH':
                    return {
                        'Cookie': f'{c.name}={c.value}'
                    }

example response:
print(get_auth_header())

{'Cookie': '.ASPXAUTH=1DC9E157078115DB9255E990EADE49A7C730035DEACF4F71559FF28438C6E10F92050B5AF0D3EA580F62565D75A8A9B788A099A3913C194C234710B1052C7DD74F942398AC78773BA8E82D1DC9E1570789031A9CC43D91A6C003C2A57C00D3DA7F40101EC2D1E9C56DDD8AB3F27E408A69BFA770789031A9025EDA596A4E38501A5CE079DA092104E392AF0D3EA580F62565D75A'}

@williamp0044
Copy link

I figured out how to obtain a cookie. But it does something weird to the scraper when you use it. My guess is because it's a different url. https://elite.finviz.com/screener.ashx rather than https://finviz.com/screener.ashx
Here's my quick code to get the cookie header. That's as far as I got for now, I may come back later and work on this more.

def get_auth_header():
    login_url = 'https://finviz.com/login_submit.ashx'
    data = {
        'email': os.environ['FINVIZ_USERNAME'],
        'password': os.environ['FINVIZ_PASSWORD']
    }
    response = requests.post(url=login_url, data=data)
    for history in response.history:
        if history.cookies:
            for c in history.cookies:
                if c.name == '.ASPXAUTH':
                    return {
                        'Cookie': f'{c.name}={c.value}'
                    }

example response:
print(get_auth_header())

{'Cookie': '.ASPXAUTH=1DC9E157078115DB9255E990EADE49A7C730035DEACF4F71559FF28438C6E10F92050B5AF0D3EA580F62565D75A8A9B788A099A3913C194C234710B1052C7DD74F942398AC78773BA8E82D1DC9E1570789031A9CC43D91A6C003C2A57C00D3DA7F40101EC2D1E9C56DDD8AB3F27E408A69BFA770789031A9025EDA596A4E38501A5CE079DA092104E392AF0D3EA580F62565D75A'}

Hi! Any luck with this? Were you able to get it working?

@DerekMelchin
Copy link

This functionality would be very helpful. +1

@bestmazzo
Copy link

bestmazzo commented Aug 9, 2022

Hello, I managed to reuse @NathanHRich code in order to make it work on another finviz library called finvizfinance. It shouldn't be difficult porting the changes here. Is anyone still interested?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants