簡體   English   中英

Web數據上的Python移動平均

[英]Python moving average on web data

如果我問一個愚蠢的問題,相對較新的python表示歉意。

我只想檢查這是否可行以及它是否復雜。

我想根據此網頁上的共享數據計算移動平均線

https://uk.finance.yahoo.com/q/hp?a=&b=&c=&d=11&e=16&f=2015&g=d&s=LLOY.L%2C+&ql=1

您可以使用此示例代碼。

import urllib
from BeautifulSoup import *

url = raw_input('Enter - ')
html = urllib.urlopen(url).read()

soup = BeautifulSoup(html)
# Retrieve all of the anchor tags
tags = soup('span')
for tag in tags:
   # Look at the parts of a tag
   #calculate whatever you wanto

試試吧:

from urllib import request
from bs4 import BeautifulSoup

url = "https://uk.finance.yahoo.com/q/hp?a=&b=&c=&d=11&e=16&f=2015&g=d&s=LLOY.L%2C+&ql=1"
html_contents = request.urlopen(url).read()

page = BeautifulSoup(html_contents, "html.parser")
el_list = page.find_all("span", {"id": "yfs_p43_lloy.l"})
print(el_list[0])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM