代码:
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup as BS
import urllib2
response=urllib2.urlopen('http://twitual.com/?user=linfen')
html=response.read()
soup=BS(html)
kk = soup.findAll('ol')[0].text
print kk
显示:
@addyyan
@hcmy
@hootsuite
@Mandyless
@metalslagcn
@Mrdaydayup
@ooof
@Poiyzy
@sakiola
@STARSTRUCK28a
@startime
@WangCephas
@wuzhiwo
@xltkxltk
@yaodu
@youbama
我需要处理后得出这样的格式:
linfen , @addyyan
linfen , @hcmy
linfen , @hootsuite
linfen , @Mandyless
linfen , @metalslagcn
linfen , @Mrdaydayup
linfen , @ooof
linfen , @Poiyzy
linfen , @sakiola
linfen , @STARSTRUCK28a
linfen , @startime
linfen , @WangCephas
linfen , @wuzhiwo
linfen , @xltkxltk
linfen , @yaodu
linfen , @youbama
我不知道现在 kk 是个什么格式的数据,数组/字典/...?
所以,还是不知道怎么才能拆开这个数据。
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup as BS
import urllib2
response=urllib2.urlopen('http://twitual.com/?user=linfen')
html=response.read()
soup=BS(html)
kk = soup.findAll('ol')[0].text
print kk
显示:
@addyyan
@hcmy
@hootsuite
@Mandyless
@metalslagcn
@Mrdaydayup
@ooof
@Poiyzy
@sakiola
@STARSTRUCK28a
@startime
@WangCephas
@wuzhiwo
@xltkxltk
@yaodu
@youbama
我需要处理后得出这样的格式:
linfen , @addyyan
linfen , @hcmy
linfen , @hootsuite
linfen , @Mandyless
linfen , @metalslagcn
linfen , @Mrdaydayup
linfen , @ooof
linfen , @Poiyzy
linfen , @sakiola
linfen , @STARSTRUCK28a
linfen , @startime
linfen , @WangCephas
linfen , @wuzhiwo
linfen , @xltkxltk
linfen , @yaodu
linfen , @youbama
我不知道现在 kk 是个什么格式的数据,数组/字典/...?
所以,还是不知道怎么才能拆开这个数据。