一个轻量级的finviz筛网刮刀

finvizlite的Python项目详细描述


芬维兹莱特

Build Status

轻量级finviz.com网站https://finviz.com/screener.ashx筛分刮板 所有代码大约有80行长,可以在finvizlite/__init__.py中找到

安装

pip install finvizlite

快速入门

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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在Hibernate中使用条件连接两个表?   Stripes框架中的java对话范围   我的内存够吗?   Jenkins Java&Selenium如何处理2个随机异常?   javascript Java websockets跨端点共享会话   java是一种测试驱动的开发方法吗?   Java客户端中的Soap连接超时,但在SOAPUI中未超时   Java LibGDX:TileMap未在顶部和右侧渲染   linux Java::process builder:bash脚本:返回的文件名正确,但fileReader引发FileNotFoundException   java Selenium单击自动随机生成的DIV/ID/LINK   比较两个忽略元素和属性顺序的XMl文件   Java无限循环/调用   java如何防止操作修改cookie?   列出未保存的Java webpanel命令   在Java中,如何解决XXXX不能作为变量求解的错误?   Java概念后期版本格式化部分