python scraping.py
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python scraping.py相关的知识,希望对你有一定的参考价值。
# -*- coding: utf-8 -*-
import requests
# For print color
import colorama
import pprint
from colorama import Fore, Back, Style
colorama.init(autoreset=True)
url = "https://finance.yahoo.com/quote/%5EIXIC?p=^IXIC"
response = requests.get(url)
data = {}
def pp(stuff):
p = pprint.PrettyPrinter(indent=4)
p.pprint(stuff)
def main():
Indicators = {"Previous Close":[],
"Open":[],
"Volume":[],
"52 Week Range":[],
"Avg. Volume":[]}
pp(response)
htmlText = response.text
for indicator in Indicators:
print(indicator)
splitList = htmlText.split(indicator)
afterFirstSplit = splitList[1].split("\">")[1]
afterSecondSplit = afterFirstSplit.split("</td>")
dataValue = afterSecondSplit[0]
Indicators[indicator].append(dataValue)
pp(Indicators)
if __name__ == '__main__':
main()
以上是关于python scraping.py的主要内容,如果未能解决你的问题,请参考以下文章
001--python全栈--基础知识--python安装
Python代写,Python作业代写,代写Python,代做Python
Python开发
Python,python,python
Python 介绍
Python学习之认识python