Skip to main content

A lightweight finviz screener scraper

Project description

##Finvizlite A lightweight finviz.com screener scraper for https://finviz.com/screener.ashx All the code is about 80 lines long and can be found in finvizlite/__init__.py

Install

pip install finvizlite

Quick start

import finvizlite as fl

# To scrape a single page use fl.scrape(url)
df = fl.scrape("https://finviz.com/screener.ashx?v=141&o=-marketcap")

# To scrape multiple pages use fl.scrape_all(url)
# scrape the dow tickers
df = fl.scrape_all("https://finviz.com/screener.ashx?v=141&f=idx_dji&o=-marketcap")

# To print the scraped urls pass print_urls=True to scrape_all() or scrape()
>>> df = fl.scrape_all("https://finviz.com/screener.ashx?v=161&f=idx_dji&o=-marketcap", print_urls=True)
https://finviz.com/screener.ashx?v=161&f=idx_dji&o=-marketcap
https://finviz.com/screener.ashx?v=161&f=idx_dji&o=-marketcap&r=21

# To limit the amount of tickers scraped pass rows=max_rows to scrape_all
>>> df = fl.scrape_all("https://finviz.com/screener.ashx?v=121&o=-marketcap", print_urls=True, rows=50)
https://finviz.com/screener.ashx?v=121&o=-marketcap
https://finviz.com/screener.ashx?v=121&o=-marketcap&r=21
https://finviz.com/screener.ashx?v=121&o=-marketcap&r=41

# Download all the tickers from Overview page (takes ~2.5 mins)
df = fl.scrape_all("https://finviz.com/screener.ashx?v=111&o=-marketcap", print_urls=True)

# Save to csv
df.to_csv("all_tickers.csv", index=False)

# Speed up scraping. By default scrape_all sleeps 0.1 seconds between requests. You can shorten(or lengthen it) by passing the sleep_interval=time_in_seconds to scrape_url to speed up or slow down scraping, but you may run into "Too many requests" errors from finviz.com if you set it too low and make too many requests in a short time.
>>>df = fl.scrape_all("https://finviz.com/screener.ashx?v=111&o=-marketcap", sleep_interval=0)
ValueError: too many requests while getting https://finviz.com/screener.ashx?v=111&o=-marketcap&r=241

# If you want a list of the pagination urls for some reason, pass print_df_only=False to scrape()
>>> urls, df = fl.scrape("https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap", return_df_only=False)
>>> urls
['https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=21', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=41', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=61', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=81', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=101', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=121', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=141', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=161', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=181', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=201', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=221', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=241', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=261', 'https://finviz.com/screener.ashx?v=111&f=sec_energy&o=-marketcap&r=281']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finvizlite-0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

finvizlite-0.1-py2.py3-none-any.whl (4.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file finvizlite-0.1.tar.gz.

File metadata

  • Download URL: finvizlite-0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for finvizlite-0.1.tar.gz
Algorithm Hash digest
SHA256 d78cda61d26599e3b8ef5f5091acf114f0522e97a5c5d17620e810e00df3d101
MD5 f747e90191fd7cd1d15d69b22ceb6621
BLAKE2b-256 2d5287a6c340cee2860a90672585a8b433a4cb556c0c7abada06bd9540f04886

See more details on using hashes here.

File details

Details for the file finvizlite-0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: finvizlite-0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for finvizlite-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 62f09298c6a211a0c34d5e69d88a6dcd539aa7a4921fc75e8f6523625c901938
MD5 1636727511c780d1c0337cb0c35b00f9
BLAKE2b-256 ac068e8ebfc21a183067cd34cf2be757151562aefa2b5f07ca63c7148635b5cb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page