ValueError: DataFrame constructor not properly called! (求大神指教)
作者:互联网
#代码设计:步骤一:获取网页信息。步骤二:对数据进行帅选。部署三对数据进行打印
import requests
import re
import pandas as pd
def GetHtml(url):
try:
r=requests.get(url)
r.raise_for_status()
r.encoding=r.raise_for_status()
return r.text
except:
return '网络异常'
def Getinfo(list,html):
pattern=re.compile(r'class="wsod_symbol">(.*?)<\/a> .*?>(.*?)<\/span>.*\n.*?class="wsod_stream">(.*?)<\/span><\/td>')
info_text=pattern.findall(html)
for item in info_text:
list.append(item)
return "list"
def InfoList(infolist):
info_text=pd.DataFrame(infolist)
print(info_text)
def main():
infolist=[]
url='http://money.cnn.com/data/dow30/'
html=GetHtml(url)
info=Getinfo(infolist, html)
InfoList(info)
main()
标签:info,infolist,url,text,html,DataFrame,properly,return,ValueError 来源: https://www.cnblogs.com/baoerdeyidongchengbao/p/12950461.html