如何在python中将for循环的结果写入数据帧

如何在python中将for循环的结果写入数据帧,python,pandas,dataframe,Python,Pandas,Dataframe,我想将for循环的输出写入dataframe url_base = 'https://testurl.ca/contacts.php?t=' url_title = ['new','notcontacted', 'engage', 'showing', 'offers',] d = [] for url in url_title: print(url) url = url_base

我想将for循环的输出写入
dataframe

url_base = 'https://testurl.ca/contacts.php?t='    
url_title = ['new','notcontacted',
               'engage',
               'showing',
               'offers',] 
d = []
for url in url_title:
    print(url)
    url = url_base+ url
    br.open(url)
 
    html_doc = br.response().read()
    soup = BeautifulSoup(html_doc, 'html.parser')
    mydivs = soup.find_all('div', [ 'card-name', 'card-activities','card-last-seen','activity-value',])
    st=''
    for div in mydivs:
        if re.search('^\([0-9][0-9][0-9]\)', div.text):
            st+=f'{div.text}\n'
        else:
            st+=f'{div.text}, '



    print(st)
循环的
结果

new    
Daniel Brown, Online: 4 days ago New , wwe@yahoo.com, (111) 212-6765
Parik Wilson, Online: 3 days ago New , zxs@yahoo.com, (232) 456-1453

notcontacted
eeew trtr, Inquired: 2 days ago, Value $864,000 New , sdfs@icloud.com, (111) 500-1111
Yusuf Yusuf, Inquired: 2 days ago, Value $509,000 New , asdf@yahoo.com, (213) 111-9610
Jim Ricard, Next: Jun 27, 2020 @ 11:18 am New , ger@yahoo.com, (232) 111-6357
Reza Wilson, Online: 3 days ago New , 4rf@yahoo.com, (342) 456-7890
我希望结果是一个数据帧

我试图创建一个空列表并将输出写入数据帧,但到目前为止没有成功

x = 1
d = {}
c = ['Name','Online','Inquired','Value', 'Email','Phone']
df = pd.DataFrame(list(d.items()), columns=c) 

谢谢

为什么不将for循环的结果存储在dict中,然后使用
pd.DataFrame.from_dict
方法?不知道如何做yetI不确定我是否理解这个问题。数据似乎结构合理。为什么不在逗号上拆分并将值存储在dict中?为什么不在dict中存储for循环的结果,然后使用
pd.DataFrame.from_dict
方法?不确定如何执行?yetI不确定我是否理解该问题。数据似乎结构合理。为什么不在逗号上拆分并将值存储在dict中?