Skip to content

Instantly share code, notes, and snippets.

@linzino7
Last active April 28, 2020 19:05
Show Gist options
  • Save linzino7/db98241f06b554379d06cd15be2fe73e to your computer and use it in GitHub Desktop.
Save linzino7/db98241f06b554379d06cd15be2fe73e to your computer and use it in GitHub Desktop.
阻擋新手學習[多頁網路爬蟲]的關鍵資料處理思維-累加 (內含影片)
# -*- coding: utf-8 -*-
import random, string
def get_one_pagedata(i):
'''
假設這個function爬取某一網頁資料。
先用亂數給予一個英文大小寫文字替代。
'''
content = random.choice(string.ascii_letters)
return "第"+str(i)+"頁內容:"+content
# 預設先設定一個空置字串
Pages = []
# range 控制抓幾頁
for i in range(10):
# 抓一個頁面
One_Page = get_one_pagedata(i)
Pages.append(One_Page)
# 印出多頁內容
print("------印出全文-------")
print(Pages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment