我有麻烦导出一个html表(表2)到一个csv文件。我试着用它来监视这个物体pd.read\u html格式但不起作用
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
import html.parser
import pandas as pd
import time
driver=webdriver.Chrome("C:/Users/Juan Diego Bernate V/Documents/Python/Practica/APIs/chromedriver.exe")
driver.get('https://www.ambito.com/contenidos/dolar-futuro.html')
res=driver.execute_script("return document.documentElement.outerHTML")
html=driver.page_source
soup= BeautifulSoup(html, 'lxml')
tabla=soup.find_all('table')
tabla2=pd.read_html(html)
dia = time.strftime("%Y%m%d")
ruta='C:/Users/Juan Diego Bernate V/'
nombre= ruta+ 'dolar_fut_rofex_2'+dia+'.csv'
tabla2.to_csv(nombre)
print (tabla2)
print (tabla)
这是错误信息,我写了所有我用的代码,以前,我认为这是不相关的。你知道吗
DevTools监听:ws://127.0.0.1:54234/DevTools/browser/6a47dd26-ab5d-4318-b858-226180882e0f 回溯(最近一次呼叫): “文件”WSDinamicoRofex.py文件,第34行,在 表2.至csv(标称) AttributeError:“list”对象没有“to\u csv”属性 希望你能帮助我
我不能很好地运行您的示例,但请尝试^{} 。这样做应该:
这将生成一个} ,非常容易操作,然后可以使用
astropy
^{或者,等价地
相关问题 更多 >
编程相关推荐