我一直在使用pd.read\uhtml试图从一个url中提取数据,但是数据是列在
标记中的,而不是。我可能错过了一个简单的教训,但我不知道用什么函数来获得一个好的结果(一个表),而不是我得到的长字符串。如有任何建议,将不胜感激! 我使用了这两种方法,得到了相同的结果:
import requests
import pandas as pd
url ='http://www.linfo.org/acronym_list.html'
dfs = pd.read_html(url, header =0)
df = pd.concat(dfs)
df
import pandas as pd
url ='http://www.linfo.org/acronym_list.html'
data = pd.read_html(url, header=0)
data[0]
输出[1]:
AMD高级微设备API应用程序编程接口ARP地址解析协议ARPANET高级研究项目代理网络作为自治系统ASCII美国信息交换标准码AT&;美国电话电报公司ATA先进技术附件ATM异步传输模式B字节BELUG Bellevue Linux用户组BGP边界网关协议
我用BeautifulSoup解析请求html中的每个标记p和br,最后的结果是一个数据帧…以后你可以把它导出到excel文件中…希望能对你有所帮助
结果如下:
相关问题 更多 >
编程相关推荐