請 AI 解析 PTT 網頁 — 生成 JSON、寫 python 爬蟲程式、開發 iOS App

ptt 看板充滿許多有趣的鄉民討論,之前彼得潘一直想出個搭配 ptt 的作業,請同學製作 ptt 文章列表的 iOS App。

可惜 ptt 官方目前尚未公開 API,因此同學沒有方便的方法取得文章列表。然而最近 AI 的出現,取得 ptt 的內容再也不是難事。由於 ptt 網頁的 html 算滿簡單的,因此 AI 可以勝任解析 html 產生 JSON & 撰寫爬蟲的任務。

以下彼得潘示範透過 GPT 4 解析 ptt 網頁,實現以下功能。

  • 將 ptt 文章列表變成 JSON。
  • 開發 ptt 文章列表的 python 爬蟲程式 — 使用連網的 AI。
  • 開發 ptt 文章列表的 python 爬蟲程式 — 使用沒連網的 AI。
  • 將 ptt 文章列表變成 iOS App。
  • 解析 ptt 的文章內容。
  • 解析 ptt 的熱門看板。
  • 解析 ptt 的表特板照片。

ptt 的統一獅看板

彼得潘以心愛的球隊統一獅看板為例,以下為統一獅最新文章列表的連結。

將 ptt 文章列表變成 JSON

請將網頁內容整理成 JSON

https://www.ptt.cc/bbs/Lions/index4079.html

{
"posts": [
{
"title": "[新聞] 這週用1000和1譜寫不凡人生 張聖豪:「好",
"author": "girl10319",
"date": "5/27"
},
{
"title": "[心得] 5/27 洲際客場:給我一顆球",
"author": "doras",
"date": "5/27"
},
{
"title": "[新聞] 與陳鴻文隔空互嗆 昨晚暴怒的羅昂解密",
"author": "micheal59",
"date": "5/27"
},
{
"title": "[閒聊] 三鬼進化成六鬼了嗎?",
"author": "shaqjeff",
"date": "5/27"
},
{
"title": "[心得] 230526 以為是久違 其實是首次",
"author": "Zhude",
"date": "5/28"
},
{
"title": "[分享] 獅王SPOTLIGHT#8獅王調查局:誰是獅子",
"author": "yuri0626",
"date": "5/28"
},
{
"title": "[新聞] 首局5割男 蘇智傑電兄弟",
"author": "girl10319",
"date": "5/28"
},
{
"title": "[轉播] 台鋼統一自辦熱身賽",
"author": "hsr7016",
"date": "5/28"
},
{
"title": "[公告] 2023 Lions 板規",
"author": "onlysnoopy",
"date": "4/10"
},
{
"title": "[情報] 職棒34年統一7-ELEVEn獅一軍賽程賽果更新",
"author": "PowderSnow",
"date": "4/01"
},
{
"title": "[公告] 2023 票務、周邊交換/贈送區",
"author": "onlysnoopy",
"date": "4/10"
},
{
"title": "[公告] 5月份置底 怒灌/黑特/閒聊區",
"author": "onlysnoopy",
"date": "5/08"
}
]
}

開發 ptt 文章列表的 python 爬蟲程式 — 使用連網的 AI

寫一個 python 程式解析 html,輸出 JSON 格式的文章清單 https://www.ptt.cc/bbs/Lions/index4079.html

import requests
from bs4 import BeautifulSoup
import json

url = "https://www.ptt.cc/bbs/Lions/index4079.html"
response = requests.get(url)

# Parse the HTML
soup = BeautifulSoup(response.text, 'html.parser')

# Find all posts
posts = soup.find_all('div', class_='r-ent')

# Initialize an empty list to store the details of each post
post_details = []

# Loop through each post
for post in posts:
# Extract the title, author, and date
title = post.find('div', class_='title').text.strip()
author = post.find('div', class_='author').text.strip()
date = post.find('div', class_='date').text.strip()

# Store the details in a dictionary
post_dict = {
'title': title,
'author': author,
'date': date
}

# Add the dictionary to the list
post_details.append(post_dict)

# Convert the list to JSON
json_output = json.dumps(post_details, ensure_ascii=False)

# Print the JSON output
print(json_output)

剛剛的爬蟲程式會印出 JSON,若想將 JSON 另外存檔,可加入以下程式。

with open('ptt.json', 'w', encoding='utf-8') as f:
json.dump(post_details, f, ensure_ascii=False, indent=4)

以下是爬蟲程式生成的 JSON。

[
{
"title": "[新聞] 這週用1000和1譜寫不凡人生 張聖豪:「好",
"author": "girl10319",
"date": "5/27"
},
{
"title": "[心得] 5/27 洲際客場:給我一顆球",
"author": "doras",
"date": "5/27"
},
{
"title": "[新聞] 與陳鴻文隔空互嗆 昨晚暴怒的羅昂解密",
"author": "micheal59",
"date": "5/27"
},
{
"title": "[閒聊] 三鬼進化成六鬼了嗎?",
"author": "shaqjeff",
"date": "5/27"
},
{
"title": "[心得] 230526 以為是久違 其實是首次",
"author": "Zhude",
"date": "5/28"
},
{
"title": "[分享] 獅王SPOTLIGHT#8獅王調查局:誰是獅子",
"author": "yuri0626",
"date": "5/28"
},
{
"title": "[新聞] 首局5割男 蘇智傑電兄弟",
"author": "girl10319",
"date": "5/28"
},
{
"title": "[轉播] 台鋼統一自辦熱身賽",
"author": "hsr7016",
"date": "5/28"
},
{
"title": "[公告] 2023 Lions 板規",
"author": "onlysnoopy",
"date": "4/10"
},
{
"title": "[情報] 職棒34年統一7-ELEVEn獅一軍賽程賽果更新",
"author": "PowderSnow",
"date": "4/01"
},
{
"title": "[公告] 2023 票務、周邊交換/贈送區",
"author": "onlysnoopy",
"date": "4/10"
},
{
"title": "[公告] 5月份置底 怒灌/黑特/閒聊區",
"author": "onlysnoopy",
"date": "5/08"
}
]

有了爬蟲程式,我們可以自由地解析任何 ptt 的文章列表。剛剛範例的連結是 https://www.ptt.cc/bbs/Lions/index4079.html,我們只要改變數字即可讀取其它頁面,比方上一頁的網址是 index4078.html。

開發 ptt 文章列表的 python 爬蟲程式 — 使用沒連網的 AI

使用沒連網的 AI 也可以寫出爬蟲程式,只要我們告訴 AI html 的相關內容。以下為彼得潘詢問 GPT 的 prompt。

寫一個 python 程式解析 html,輸出 JSON 格式的文章清單,每篇文章包含 4 個欄位,
標題,作者,日期和推文數量,其中推文數量的型別為字串

html 的網址是
https://www.ptt.cc/bbs/Lions/index4079.html

以下是 html 裡某篇文章的區塊內容,div class nerc 的內容是推文數量

<div class=”r-ent”>
<div class=”nrec”><span class=”hl f3">14</span></div>
<div class=”title”>

<a href=”/bbs/Lions/M.1685235897.A.A1F.html”>[新聞] 首局5割男 蘇智傑電兄弟</a>

</div>
<div class=”meta”>
<div class=”author”>girl10319</div>
<div class=”article-menu”>

<div class=”trigger”>&#x22ef;</div>
<div class=”dropdown”>
<div class=”item”><a href=”/bbs/Lions/search?q=thread%3A%5B%E6%96%B0%E8%81%9E%5D&#43;%E9%A6%96%E5%B1%805%E5%89%B2%E7%94%B7&#43;%E8%98%87%E6%99%BA%E5%82%91%E9%9B%BB%E5%85%84%E5%BC%9F”>搜尋同標題文章</a></div>

<div class=”item”><a href=”/bbs/Lions/search?q=author%3Agirl10319">搜尋看板內 girl10319 的文章</a></div>

</div>

</div>
<div class=”date”> 5/28</div>
<div class=”mark”></div>
</div>
</div>

from bs4 import BeautifulSoup
import json
import requests

# 網頁 URL
url = "https://www.ptt.cc/bbs/Lions/index4079.html"

# 用 requests 取得網頁內容
response = requests.get(url)
html_content = response.text

# 用 BeautifulSoup 解析 html
soup = BeautifulSoup(html_content, 'html.parser')

# 尋找所有的文章區塊
article_blocks = soup.find_all('div', class_='r-ent')

# 建立文章清單
articles = []

for block in article_blocks:
title_block = block.find('div', class_='title').find('a')
title = title_block.text if title_block else "N/A" # 標題
author = block.find('div', class_='author').text # 作者
date = block.find('div', class_='date').text.strip() # 日期
nrec_block = block.find('div', class_='nrec').find('span')
nrec = nrec_block.text if nrec_block else "0" # 推文數量,儲存為字串型別

articles.append({
'title': title,
'author': author,
'date': date,
'nrec': nrec,
})

# 將文章清單轉為 JSON 格式並輸出
articles_json = json.dumps(articles, ensure_ascii=False, indent=4)
print(articles_json)

以下是爬蟲程式生成的 JSON。

[
{
"title": "[新聞] 這週用1000和1譜寫不凡人生 張聖豪:「好",
"author": "girl10319",
"date": "5/27",
"nrec": "14"
},
{
"title": "[心得] 5/27 洲際客場:給我一顆球",
"author": "doras",
"date": "5/27",
"nrec": "17"
},
{
"title": "[新聞] 與陳鴻文隔空互嗆 昨晚暴怒的羅昂解密",
"author": "micheal59",
"date": "5/27",
"nrec": "17"
},
{
"title": "[閒聊] 三鬼進化成六鬼了嗎?",
"author": "shaqjeff",
"date": "5/27",
"nrec": "X1"
},
{
"title": "[心得] 230526 以為是久違 其實是首次",
"author": "Zhude",
"date": "5/28",
"nrec": "7"
},
{
"title": "[分享] 獅王SPOTLIGHT#8獅王調查局:誰是獅子",
"author": "yuri0626",
"date": "5/28",
"nrec": "16"
},
{
"title": "[新聞] 首局5割男 蘇智傑電兄弟",
"author": "girl10319",
"date": "5/28",
"nrec": "14"
},
{
"title": "[轉播] 台鋼統一自辦熱身賽 ",
"author": "hsr7016",
"date": "5/28",
"nrec": "爆"
},
{
"title": "[公告] 2023 Lions 板規",
"author": "onlysnoopy",
"date": "4/10",
"nrec": "0"
},
{
"title": "[情報] 職棒34年統一7-ELEVEn獅一軍賽程賽果更新",
"author": "PowderSnow",
"date": "4/01",
"nrec": "6"
},
{
"title": "[公告] 2023 票務、周邊交換/贈送區",
"author": "onlysnoopy",
"date": "4/10",
"nrec": "爆"
},
{
"title": "[公告] 5月份置底 怒灌/黑特/閒聊區",
"author": "onlysnoopy",
"date": "5/08",
"nrec": "15"
}
]

將 ptt 文章列表變成 iOS App

請用 SwiftUI 的 List 顯示網頁內容 https://www.ptt.cc/bbs/Lions/index4079.html

import SwiftUI

struct ContentView: View {
let posts: [Post] = [
Post(title: "[新聞] 這週用1000和1譜寫不凡人生 張聖豪:「好", author: "girl10319"),
Post(title: "[心得] 5/27 洲際客場:給我一顆球", author: "doras"),
Post(title: "[新聞] 與陳鴻文隔空互嗆 昨晚暴怒的羅昂解密", author: "micheal59"),
Post(title: "[閒聊] 三鬼進化成六鬼了嗎?", author: "shaqjeff"),
Post(title: "[心得] 230526 以為是久違 其實是首次", author: "Zhude"),
Post(title: "[分享] 獅王SPOTLIGHT#8獅王調查局:誰是獅子", author: "yuri0626"),
Post(title: "[新聞] 首局5割男 蘇智傑電兄弟", author: "girl10319"),
Post(title: "[轉播] 台鋼統一自辦熱身賽 ", author: "hsr7016"),
]

var body: some View {
List(posts) { post in
VStack(alignment: .leading) {
Text(post.title).font(.headline)
Text(post.author).font(.subheadline)
}
}
}
}

struct Post: Identifiable {
let id = UUID()
let title: String
let author: String
}

學會以上技巧後,我們可以用同樣方法解析 ptt 的其它資料,比方文章內容,熱門看板和表特板照片。

解析 ptt 的文章內容

以下我們請 AI 撰寫爬蟲程式解析文章內容。

文章內容的爬蟲程式。

import requests
from bs4 import BeautifulSoup
import json

url = 'https://www.ptt.cc/bbs/Lions/M.1685235897.A.A1F.html'

res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')

# Extract the post's metadata
meta_data = {
'author': soup.find('div', {'class': 'article-metaline'}).find('span', {'class': 'article-meta-value'}).text,
'title': soup.find_all('div', {'class': 'article-metaline'})[1].find('span', {'class': 'article-meta-value'}).text,
'date': soup.find_all('div', {'class': 'article-metaline'})[2].find('span', {'class': 'article-meta-value'}).text,
}

# Extract the post's content
content = soup.find('div', {'id': 'main-content'}).text

# Extract the comments
comments = []
for comment in soup.find_all('div', {'class': 'push'}):
push_tag = comment.find('span', {'class': 'push-tag'}).text.strip()
push_userid = comment.find('span', {'class': 'push-userid'}).text.strip()
push_content = comment.find('span', {'class': 'push-content'}).text.strip()
push_time = comment.find('span', {'class': 'push-ipdatetime'}).text.strip()
comments.append({
'tag': push_tag,
'userid': push_userid,
'content': push_content,
'time': push_time,
})

# Combine all data
data = {
'meta_data': meta_data,
'content': content,
'comments': comments,
}

# Convert data to JSON
json_data = json.dumps(data, ensure_ascii=False, indent=4)

# Print the JSON data
print(json_data)

爬蟲程式產生的 JSON 十分完整,除了完整的文章內容,還包含了鄉民精彩的留言。

{
"meta_data": {
"author": "girl10319 (凱莉)",
"title": "[新聞] 首局5割男 蘇智傑電兄弟",
"date": "Sun May 28 09:04:54 2023"
},
"content": "作者girl10319 (凱莉)看板Lions標題[新聞] 首局5割男 蘇智傑電兄弟時間Sun May 28 09:04:54 2023\n首局5割男 蘇智傑電兄弟\n\n記者羅志朋/台中報導\n\n「球給智傑」就對了!統一獅蘇智傑昨繳3安猛打賞,包含1發陽春砲,打下3分打點獲選\n單場MVP,加上洋投勝騎士先發7局失1分,攜手助隊以5:1擊敗中信兄弟拿下4連勝。\n\n開轟猛打賞 3數據居榜首\n\n首局蘇智傑擊出2分打點安打,3局上再轟陽春砲,苦主都是兄弟先發投手鄭浩均,7局上\n老將陳鏞基敲2分打點安打奠定勝基,鄭浩均投4局被敲6安失3分苦吞本季第2敗;蘇智傑\n累計3成67打擊率、47安、31分打點,都暫居全聯盟第一。\n\n去年開季蘇智傑因自打球造成右膝髕骨骨裂動刀,只出賽15場,本季破繭而出,獅隊總教\n練林岳平表示,蘇智傑去年受傷急著回歸陣線,結果舊傷復發,今年春訓希望他放慢腳步\n,開季逐漸加溫即可,不用一下衝太快。\n\n獅4連勝 洋投陣功不可沒\n\n本季蘇智傑首局累計22打數敲11安,打擊率高達5成,進帳12分打點,堪稱「首局火熱男\n」,他笑說,「要感謝隊友啦,如果他們首局沒上壘,我也沒機會賺打點,今年心態正向\n很多,攻擊策略也很明確,喜歡的球就毫不猶豫出棒。」\n\n連同勝騎士先發7局失1分奪下個人第3勝,近期獅隊4連勝都由洋投先發,羅昂、布雷克、\n克維斯、勝騎士依序登板,總計投27局只掉3分,本季獅隊洋投戰績13勝7敗、防禦率2.26\n,目前以勝率5成83暫居榜首,洋投強勢表現功不可沒。\n\n林岳平認為,比賽勝負關鍵在3局下,當時勝騎士接連被敲安後取得兩出局,再被岳政華\n擊出右外野長打,但林安可、陳重廷迅速轉傳回本壘觸殺跑者岳東華結束攻勢,若讓岳東\n華得分,下一棒是周思齊,有可能形成大局。\n\nhttps://sports.ltn.com.tw/news/paper/1585393\n\n--\n※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 110.28.25.135 (臺灣)\n※ 文章網址: https://www.ptt.cc/bbs/Lions/M.1685235897.A.A1F.html\n推 KoreanDream : OPS+204.6的男人 05/28 11:28\n推 a22580144 : 不要再報了 我很擔心台南鄭先生的週報 被嗨到 05/28 12:12\n推 gaga : 樓上 我看那是必然的了 05/28 12:19\n推 NumberOne : 目前智傑這樣子的成績,才是當初選他進來時,對他 05/28 12:30\n→ NumberOne : 天份兌現的期待,也就是年度mvp競爭者等級的打擊表 05/28 12:30\n→ NumberOne : 現 05/28 12:30\n推 NumberOne : 今年他醒來真的欣慰,不然前幾年的打擊變化,會擔憂 05/28 12:37\n→ NumberOne : 是不是長歪了 05/28 12:37\n推 FantasyChopi: 拜託不要再被嗨了 05/28 12:44\n推 youarepig999: 完了要上嗨報了XD 05/28 12:57\n→ oocooc : 又要被嗨了 05/28 13:06\n推 YaLuBigRock : 打成這樣如果鄭先生不講他就是私心了 05/28 13:34\n推 GoIce : 太強惹 05/28 13:43\n→ Gcobs130275 : 協尋 05/28 13:49\n推 sluggers : https://i.imgur.com/lfUWSW5.jpg 05/28 16:39\n推 LionFans : 智傑打擊王真的不習慣 憲打擊or安打 智打點 安HR王 05/28 18:52\n→ LionFans : 這樣好像比較正常 XD 05/28 18:54\n→ granturismo : 憲今年應該是生涯最低潮年吧 05/28 19:04\n→ goetze : 其實這幾場陳傑憲有回穩的跡象 05/28 19:46\n推 Iori2010 : 被樓主\"協尋\"之後,居然變回20上半季的球給智傑 05/28 20:39\n→ castlewind : 協尋完以後大爆發 05/28 20:41\n推 allyp7985 : 憲哪是最低潮年,ops+ 還有132,他最差是116 05/28 22:13\n推 IANSUE : 智傑突然就醒了~ 05/28 22:41\n",
"comments": [
{
"tag": "推",
"userid": "KoreanDream",
"content": ": OPS+204.6的男人",
"time": "05/28 11:28"
},
{
"tag": "推",
"userid": "a22580144",
"content": ": 不要再報了 我很擔心台南鄭先生的週報 被嗨到",
"time": "05/28 12:12"
},
{
"tag": "推",
"userid": "gaga",
"content": ": 樓上 我看那是必然的了",
"time": "05/28 12:19"
},
{
"tag": "推",
"userid": "NumberOne",
"content": ": 目前智傑這樣子的成績,才是當初選他進來時,對他",
"time": "05/28 12:30"
},
{
"tag": "→",
"userid": "NumberOne",
"content": ": 天份兌現的期待,也就是年度mvp競爭者等級的打擊表",
"time": "05/28 12:30"
},
{
"tag": "→",
"userid": "NumberOne",
"content": ": 現",
"time": "05/28 12:30"
},
{
"tag": "推",
"userid": "NumberOne",
"content": ": 今年他醒來真的欣慰,不然前幾年的打擊變化,會擔憂",
"time": "05/28 12:37"
},
{
"tag": "→",
"userid": "NumberOne",
"content": ": 是不是長歪了",
"time": "05/28 12:37"
},
{
"tag": "推",
"userid": "FantasyChopi",
"content": ": 拜託不要再被嗨了",
"time": "05/28 12:44"
},
{
"tag": "推",
"userid": "youarepig999",
"content": ": 完了要上嗨報了XD",
"time": "05/28 12:57"
},
{
"tag": "→",
"userid": "oocooc",
"content": ": 又要被嗨了",
"time": "05/28 13:06"
},
{
"tag": "推",
"userid": "YaLuBigRock",
"content": ": 打成這樣如果鄭先生不講他就是私心了",
"time": "05/28 13:34"
},
{
"tag": "推",
"userid": "GoIce",
"content": ": 太強惹",
"time": "05/28 13:43"
},
{
"tag": "→",
"userid": "Gcobs130275",
"content": ": 協尋",
"time": "05/28 13:49"
},
{
"tag": "推",
"userid": "sluggers",
"content": ": https://i.imgur.com/lfUWSW5.jpg",
"time": "05/28 16:39"
},
{
"tag": "推",
"userid": "LionFans",
"content": ": 智傑打擊王真的不習慣 憲打擊or安打 智打點 安HR王",
"time": "05/28 18:52"
},
{
"tag": "→",
"userid": "LionFans",
"content": ": 這樣好像比較正常 XD",
"time": "05/28 18:54"
},
{
"tag": "→",
"userid": "granturismo",
"content": ": 憲今年應該是生涯最低潮年吧",
"time": "05/28 19:04"
},
{
"tag": "→",
"userid": "goetze",
"content": ": 其實這幾場陳傑憲有回穩的跡象",
"time": "05/28 19:46"
},
{
"tag": "推",
"userid": "Iori2010",
"content": ": 被樓主\"協尋\"之後,居然變回20上半季的球給智傑",
"time": "05/28 20:39"
},
{
"tag": "→",
"userid": "castlewind",
"content": ": 協尋完以後大爆發",
"time": "05/28 20:41"
},
{
"tag": "推",
"userid": "allyp7985",
"content": ": 憲哪是最低潮年,ops+ 還有132,他最差是116",
"time": "05/28 22:13"
},
{
"tag": "推",
"userid": "IANSUE",
"content": ": 智傑突然就醒了~",
"time": "05/28 22:41"
}
]
}

解析 ptt 的熱門看板

以下我們請 AI 撰寫爬蟲程式解析熱門看板。

熱門看板的爬蟲程式。

import requests
from bs4 import BeautifulSoup
import json

def parse_hotboards(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

hotboards = []

# Based on the provided HTML structure, we know that each board is represented by a 'div' with class 'b-ent'
for board_div in soup.find_all('div', class_='b-ent'):
board_details = {}

# Each detail about the board is contained in a 'div' within the 'b-ent' div.
# We can find these using the BeautifulSoup .find method, and then get the text within the div.
board_details['name'] = board_div.find('div', class_='board-name').text
board_details['popularity'] = board_div.find('div', class_='board-nuser').text
board_details['category'] = board_div.find('div', class_='board-class').text
board_details['title'] = board_div.find('div', class_='board-title').text

hotboards.append(board_details)

return json.dumps(hotboards)

# Use the function
json_hotboards = parse_hotboards('https://www.ptt.cc/bbs/hotboards.html')
print(json_hotboards)

爬蟲程式產生的 JSON。

解析 ptt 的表特板照片

以下我們請 AI 解析表特板文章,撰寫爬蟲程式將文章裡的圖片網址整理成 JSON。

以下連結充滿了 IU 可愛的照片。

表特板文章的爬蟲程式如下,記得要設定 http header 的 Cookie 是 over18=1,這樣才能跳過 18 歲的檢查抓資料。

import requests
from bs4 import BeautifulSoup
import json

def parse_images(url):
# Set the headers for the request
headers = {
'Cookie': 'over18=1'
}

response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')

images = []

# Select all 'a' elements
for a in soup.select('a'):
# Get the 'href' attribute of the 'a' tag, which is the image URL
image_url = a.get('href')
# Check if the href link is an image by checking if it ends with .jpg, .png, etc. Adjust the list of image extensions based on your needs.
if image_url and any(image_url.endswith(ext) for ext in ['.jpg', '.png', '.jpeg', '.gif']):
images.append(image_url)

return json.dumps(images)

# Use the function
json_images = parse_images('https://www.ptt.cc/bbs/Beauty/M.1684173602.A.28F.html')
print(json_images)

爬蟲程式產生的 JSON。

[
"https://i.imgur.com/G2fjckg.jpg",
"https://i.imgur.com/wjj5F4p.jpg",
"https://i.imgur.com/rXfBuJF.jpg",
"https://i.imgur.com/VNNo3es.jpg",
"https://i.imgur.com/41kOMLq.jpg",
"https://i.imgur.com/k1eKksN.jpg",
"https://i.imgur.com/MCrQ89P.jpg",
"https://i.imgur.com/Gla7hbN.jpg",
"https://i.imgur.com/DjxL24f.jpg",
"https://i.imgur.com/lwSIMhp.jpg",
"https://i.imgur.com/dAAVCt5.jpg",
"https://i.imgur.com/FUdTW0v.jpg",
"https://i.imgur.com/twZPqdO.jpg",
"https://i.imgur.com/I3LlEu8.jpg",
"https://i.imgur.com/uNfnu40.jpg",
"https://i.imgur.com/ZgRiuzo.jpg",
"https://i.imgur.com/s5KGpWL.jpg",
"https://i.imgur.com/8QW22PO.jpg",
"https://i.imgur.com/VBSmow4.jpg",
"https://i.imgur.com/9d20i3c.jpg",
"https://i.imgur.com/3VqYRkH.jpg",
"https://i.imgur.com/4PyRGcy.jpg",
"https://i.imgur.com/e8L8i8I.jpg",
"https://i.imgur.com/p3cJRIg.jpg",
"https://i.imgur.com/QtdpSvO.jpg",
"https://i.imgur.com/DYnLlaw.jpg",
"http://i.imgur.com/v31HHor.jpg",
"https://i.imgur.com/cg4zCVV.gif",
"https://i.imgur.com/oj5hjsN.jpg"
]

作業練習

開發 iOS App 顯示 ptt 的內容,JSON 資料可事先透過剛剛的 ptyhon 程式生成,然後將 JSON 檔放在 GitHub 上。

ps: ptt 也正在開發官方的 iOS App,有興趣的朋友可參考以下連結。

--

--

彼得潘的 iOS App Neverland
彼得潘的 Swift iOS App 開發問題解答集

彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,彼得潘的 Swift 程式設計入門,App程式設計入門作者,http://apppeterpan.strikingly.com