web上的Python移动平均

2024-05-18 23:41:44 发布

您现在位置:Python中文网/ 问答频道 /正文

对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


Tags: 数据httpscom网页yahoohp平均值finance
2条回答

您可以使用此示例代码。你知道吗

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

相关问题 更多 >

    热门问题