Git Product home page Git Product logo

Comments (16)

miko1ann avatar miko1ann commented on May 18, 2024 1

Workaround with selenium

`
def fetcher (url, lines=False):
print ('>>>', url)
driver.get(url)
res = WebDriverWait(driver, 100).until( lambda driver: driver.find_element(By.XPATH, "//*").get_attribute('outerHTML'))
if lines:
res = res.split('\n')
return res

...

exporter = Exporter(fetcher = fetcher)

`

from finam-export.

am1ter avatar am1ter commented on May 18, 2024 1

@Celeevo I used code above and created new version of the lib. You can install it with: pip install git+https://github.com/am1ter/finam-export
I also created pull request, but before you can use it, you have to wait until @ffeast review it and publish.

from finam-export.

Celeevo avatar Celeevo commented on May 18, 2024 1

@am1ter Thanks a lot, it works now!

from finam-export.

ffeast avatar ffeast commented on May 18, 2024

Yes it seems so. Would be happy to see a pull request because I don't have spare time to figure it out

from finam-export.

miko1ann avatar miko1ann commented on May 18, 2024

I tryed to replace user-agent but error stil repduces. So problen is in securuty policy of finam api.

from finam-export.

anatoliakor avatar anatoliakor commented on May 18, 2024

Yes it seems so. Would be happy to see a pull request because I don't have spare time to figure it out

I tryed to replace user-agent but error stil repduces. So problen is in securuty policy of finam api.

yes, i did the same and got same result... it seems that security protection distinguishes somehow differently (not by user-agent). i stopped attemts to figure it out and starting to find another way to get stocks quotes

from finam-export.

ffeast avatar ffeast commented on May 18, 2024

Interesting. Pull request?

from finam-export.

miko1ann avatar miko1ann commented on May 18, 2024

No nesessary, just copy and use. Also this way contains issue with encoding for cyrilyc symbols.

update

def fetcher (url, lines=False):
print ('>>>', url)
driver.get(url)
res = WebDriverWait(driver, 100).until( lambda driver: driver.find_element(By.XPATH, "//*").get_attribute('outerHTML'))
if lines:
res = res.encode('cp1252').decode('cp1251') # <
res = res.split('\n') # <
return res

UPD 28.01.23: Working solution

from finam-export.

Celeevo avatar Celeevo commented on May 18, 2024

Добрый день,
если у кого-то получилось исправить доступ с помощью описанной выше заплатки, поделитесь пжлст для тех кто в танке - куда копировать новый fetcher и что дополнительно нужно импортировать (driver, WebDriver..., etc)

from finam-export.

miko1ann avatar miko1ann commented on May 18, 2024

Complete workaround, contains downloading data.

def fetcher (url, lines=False):
print ('>>>', url)
driver.get(url)
res = WebDriverWait(driver, 15).until( lambda driver: driver.find_element(By.XPATH, "//*").get_attribute('outerHTML'))
if lines:
res = res.encode('cp1252').decode('cp1251')
res = res.split('\n')
return res

def fetcher_download(url, readlines = False):
print ('>>>', url)
r = requests.get(url, headers = {'User-Agent':'Mozilla 8'}, stream=True)
return r.content.decode('utf8')
if lines:
return r.content.decode('utf8').split('\n\r')
else :
return r.content.decode('utf8')

exporter = Exporter(fetcher = fetcher)
exporter._fetcher = fetcher_download

I think this solution is temorary, until Finam changes an autorisation of the web downloading page.
Different way to reanimate project is research workarount to extract token and pass it to request (to awoid webdriver...)
So its looks like strange, because they are produces acess to stock data throw web page(free), and connector with .net lib (login:password), but dont provides api...

from finam-export.

miko1ann avatar miko1ann commented on May 18, 2024

Thanks @ffeast fo the extensible and clear code.

from finam-export.

ffeast avatar ffeast commented on May 18, 2024

Hi
@am1ter commented on the PR, please check. The overall takeaway is that now it looks too complex with 2 different fetchers and all classes being aware of that

from finam-export.

am1ter avatar am1ter commented on May 18, 2024

Hi @am1ter commented on the PR, please check. The overall takeaway is that now it looks too complex with 2 different fetchers and all classes being aware of that

Hello @ffeast ! Thank you for a quick response. I don't see any comment to the PR at the moment. I am not sure why.

On one hand, I agree with you that it is not the best decision to have two independant fetchers in Exporter class. By the other hand, it gives a user an option to declare using standart urllib fetcher manually in the case if token-protection will be disabled one day.
Also, as I see there is an alternative way to use second fetcher. For example, try to use urllib-based fetcher and in the case of the error use webdriver-based fetcher. However, I see some downsides in this soltions as well.

What do you think? Or maybe you can even suggest more effective solution?

from finam-export.

ffeast avatar ffeast commented on May 18, 2024

Hi
Could you please check if any of the comments are seen on this page or here?

from finam-export.

am1ter avatar am1ter commented on May 18, 2024

Hi Could you please check if any of the comments are seen on this page or here?

Hello @ffeast! Unfortunately, not. And it is quite strange. Look at the screenshot 1 and screenshot 2.

from finam-export.

am1ter avatar am1ter commented on May 18, 2024

@ffeast Hello again! So, since I don't see any comment on the PR page maybe you can post it here?

from finam-export.

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.