2 回答
TA贡献1831条经验 获得超9个赞
您可以每隔一分钟尝试一次:
from bs4 import BeautifulSoup
import requests
import time # you need this module
# this will run forever
while True:
result = requests.get("https://liveindex.org/s&p-futures/")
src = result.content
soup = BeautifulSoup(src, 'lxml')
table_body=soup.find('tbody')
rows = table_body.find_all('tr')
for row in rows:
cols=row.find_all('td')
cols=[x.text.strip() for x in cols]
print(cols)
time.sleep(120) # this will wait for 120 seconds
TA贡献1829条经验 获得超7个赞
from bs4 import BeautifulSoup
import requests
**import time**
**While True:**
result = requests.get("https://liveindex.org/s&p-futures/")
src = result.content
soup = BeautifulSoup(src, 'lxml')
table_body=soup.find('tbody')
rows = table_body.find_all('tr')
for row in rows:
cols=row.find_all('td')
cols=[x.text.strip() for x in cols]
print(cols)
**time.sleep(120)**
添加回答
举报