【发布时间】:2019-06-08 12:06:57
【问题描述】:
请帮助我使用 BeautifulSoup 使用 Python 3 从investment.com 网络抓取财务值。 无论我做什么都不会获得任何价值,并且过滤类正在从网页永久更改,它是一个实时值。
import requests
from bs4 import BeautifulSoup
url = "https://es.investing.com/indices/spain-35-futures"
precio_objetivo = input("Introduce el PRECIO del disparador:")
precio_objetivo = float(precio_objetivo)
print (precio_objetivo)
while True:
html = requests.get(url).text
soup = BeautifulSoup(html, "html.parser")
precio_actual = soup.find('span', attrs={'class': 'arial_26 inlineblock pid-8828-last','id':'last_last','dir':'ltr'})
print (precio_actual)
break;
当我不在soup.find 应用任何过滤器时(至少尝试获取所有网页)我得到这个结果:
<bound method Tag.find_all of
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>403 You are banned from this site. Please contact via a different client configuration if you believe that this is a mistake. </title>
</head>
<body>
<h1>Error 403 You are banned from this site. Please contact via a different client configuration if you believe that this is a mistake.</h1>
<p>You are banned from this site. Please contact via a different client configuration if you believe that this is a mistake.</p>
<h3>Guru Meditation:</h3>
<p>XID: 850285196</p>
<hr/>
<p>Varnish cache server</p>
</body>
</html>
【问题讨论】:
标签: beautifulsoup