[問題] 迴圈dataframe資料的匯出
大家好,
寫了一個小爬蟲,因為擷取的資料為dataframe,迴圈結果都只輸出最後一次,
請問該如何讓每次迭代的結果,按照row堆疊下去呢?
-------------------------------------------------------------
urls =
['http://www.fishbase.org/popdyn/PopGrowthList.php?ID=22903&GenusName=Abbottina&SpeciesName=rivularis&fc=122',
'http://www.fishbase.org/popdyn/PopGrowthList.php?ID=972&GenusName=Ablennes&SpeciesName=hians&fc=207',
'http://www.fishbase.org/popdyn/PopGrowthList.php?ID=268&GenusName=Abramis&SpeciesName=brama&fc=122']
for url in urls:
QWQ = re.findall(r"=(\w+)&", url)
fish = pd.read_html(url)[1].assign(id=QWQ[0],gnema=QWQ[1],snema=QWQ[2])
pd.concat([fish], axis=0)
print(fish)
--------------------------------------------------------------------------------
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.70.50
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1517315501.A.67D.html
→
01/31 00:33,
7年前
, 1F
01/31 00:33, 1F
→
01/31 09:03,
7年前
, 2F
01/31 09:03, 2F
→
01/31 09:15,
7年前
, 3F
01/31 09:15, 3F
→
01/31 09:16,
7年前
, 4F
01/31 09:16, 4F
→
01/31 09:16,
7年前
, 5F
01/31 09:16, 5F
→
01/31 10:11,
7年前
, 6F
01/31 10:11, 6F
Python 近期熱門文章
PTT數位生活區 即時熱門文章