Code Monkey home page Code Monkey logo

Comments (4)

DerekMelchin avatar DerekMelchin commented on July 20, 2024 1

This functionality would be very helpful. +1

from finviz.

NathanHRich avatar NathanHRich commented on July 20, 2024

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'}

from finviz.

williamp0044 avatar williamp0044 commented on July 20, 2024

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?

from finviz.

bestmazzo avatar bestmazzo commented on July 20, 2024

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?

from finviz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.