♚尼腓工作室♚ 爬蟲 漢堡王GT 自動完成?
簡介
基於每月都要填寫相同問卷,究竟是否可以利用程式來完成呢?就讓我們來一探究竟吧~!
有任何建議可在下方留言給建議歐~
關於我們 ♚尼腓工作室
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼保證金賣家安心可靠
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
主要業務 :
- 代儲專區 : 多款日韓手遊優惠代儲。
- 動漫周邊 : 客製化動漫周邊 (抱枕、掛軸、床單、壓克力立牌吊飾),可來圖訂製。
- 點卡專區 : GASH、Mycard、貝殼幣等點卡95折起。
- 程式課程 : 零基礎Python入門 ( 團體/1對1 ) 線上課程、專案製作 。
優惠專區 :
代儲系列商品可轉帳付款,免去平台抽成享優惠價格,可至下方聯絡方式詢問。
聯絡方式
免責申明
本文並非教學文章,只附上片段程式碼說明構思,僅做學術研究,無破壞問卷可靠性之意,若有違反請告知,將盡速移除。
什麼是爬蟲 ?
根據維基百科所述,網路爬蟲(英語:web crawler),也叫網路蜘蛛(spider),是一種用來自動瀏覽全球資訊網的網路機器人。
網路搜尋引擎等站點通過爬蟲軟體更新自身的網站內容或其對其他網站的索引。網路爬蟲可以將自己所存取的頁面儲存下來,以便搜尋引擎事後生成索引供使用者搜尋。
簡單來說,可以透過程式碼對網頁進行自動化操作,只是要填個簡單問卷而已,當然是沒問題的拉 ~!
我們將分次進行講解,無論是否學過程式,看完文章都能對網頁結構、爬蟲邏輯有初步的了解。
影片展示
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
開發環境
編譯器: Visual Studio Code (VSC)
程式語言:Python3
爬蟲套件:Selenium、Jupyter、ChromeDriver
目錄與構思
漢堡王GT問卷大致分為以下幾個部分,
市場模型
既然花費時間製作,我們當然不可能讓機器人每個選項都亂填,這樣做的問卷毫無參考價值,這樣真的就是在破壞問卷可靠度,可根據各門市所在地、當月營運調整模型結構,讓問卷更接近真實狀況。
可調整比例權重如下,權重說明:權重總和可不必等於100%,
舉例:投擲一枚不公平的硬幣80次正面、50次反面,其權重為(正面:80%反面:50%)
▼ 點餐類型
點餐預設權重(內用:50%,外帶:50%,送餐上門:0%)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼ 客人人數統計
人數預設權重: (1人:40%, 2人:35%, 3人:15%, 4人以上:10%)
PS: 人數與滿意度留言掛勾,幾個人就購買幾份餐點 (餐點不重複出現)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼ 顧客性別
性別預設權重: (40%, 40%, 1%, 4%, 15%)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼ 顧客性年齡
年齡預設權重: (10%, 20%, 30%, 20%, 10%, 10%)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼ 本月購買頻率
頻率預設權重: (1次:10%, 2次:20%, 3次:25%, 4次:20%, 5次:25%)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼ 購買原因
原因預設權重: (1%,1%,1%,1%,1%,1%,1%,1%) 預設權重相同
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
下拉式選單與表格輸入: [GT代碼與時間]
▼ GT問卷範例
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼ 問卷網站日期格式 (12小時制)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
問卷單上有調查代碼、購買時間(24時制),調查代碼可直接使用,而購買時間與調查網站上時間格式不同,需進行轉換,程式碼如下。
程式碼 日期格式轉換
呼叫示範
隨機單選框點選: [點餐類型(內用、外帶)]
台灣目前並無門市有送餐上門的服務,但網頁中有時會有送餐上門的選項,我們需要排除在外。只在內用、外帶中隨機挑選一個。
▼ 點餐類型基本款
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
▼ 點餐類型特殊款
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
利用隨機數隨機點選內用或外帶選項
固定單選框點選: [滿意度調查、是否遇到問題、是否推薦餐廳]
這個區塊中我們希望的回答均為固定的選項,但有時網頁會出現不規律的變動,可能增加按鈕選項,又或者是改變滿意度順序("非常滿意","非常不滿意") 的位置,那我們就不能使用固定的寫法,那我們該如何做呢?
樣本圖
- 1.滿意度調查_基本款 [非常滿意] (5種選項)

▼ 滿意度調查_基本款(網頁程式碼) [6個單選框]

- 1.滿意度調查_特例 [非常滿意] (6種選項)

▼ 滿意度調查_特例 (網頁程式碼) [6個單選框]

-
2.是否遇到問題? [否] (2種選項)

-
3.是否推薦餐廳 [非常可能] (5種選項)

結論
經觀察,無論有幾個選項、題目、出現例外情形,程式碼中每列的單選框單選框(radio)數量均相同,只要找出案選項的種類、期望選項之結果、單選框總數,透過迴圈套用公式就可點選所有我們希望的選項。
舉例 : 有5個選項、3個題目、共15個單選框,假設我們希望點選全部 選項3
的選項
|
選項1 |
選項2 |
選項3
|
選項4 |
選項5 |
第一題 |
按鈕1 |
按鈕2 |
按鈕3
|
按鈕4 |
按鈕5 |
第二題 |
按鈕6 |
按鈕7 |
按鈕8
|
按鈕9 |
按鈕10 |
第三題 |
按鈕11 |
按鈕12 |
按鈕13
|
按鈕14
|
按鈕15 |
公式: 按鈕編號 % 按鈕總數 = 希望選項編號 (%取餘數)
說明: 當算出來的餘數等於希望的選項編號時就代表是我們希望點選的選項。
單選按鈕 |
公式運算 |
比較 |
執行 |
按鈕2 |
2 % 5 = 2 |
2 != 3 |
✗ 不動作 |
按鈕3 |
3 % 5 = 3 |
3 = 3 |
✓ 點選 |
按鈕4 |
4 % 5 = 4 |
4 != 3 |
✗ 不動作 |
按鈕8 |
8 % 5 = 3 |
3 = 3 |
✓ 點選 |
按鈕13 |
13 % 5 = 3 |
3 = 3 |
✓ 點選 |
按鈕14 |
14 % 5 = 4 |
4 != 3 |
✗ 不動作 |
按照這個公式無論有幾種選項,是否有調換滿意度順序,我們都可以點選到我們希望的選項。
程式碼片段
隨機生成評價留言
▼ GT問卷滿意原因

我們當然不可能事先寫好多篇文章,然後隨機挑選一篇,這樣不僅需花費大量時間構思,多提交幾次問卷時,會有許多一模一樣的留言顯得很不自然,那該如何做呢?
我們可將文字拆分品項、以及形容詞,
例:水果: [蘋果、葡萄、芭樂、蓮霧] ,形容詞: [香甜多汁、汁水飽滿、品項很好]
假設有4種水果與3個形容詞,這樣就能產生出 4 * 3 = 12 種結果。
利用這個方法套用在漢堡王上,我們可以分類為主餐、點心、飲品與最後的評價。
以下方程式碼為例 (內用且每種選項均出現1次)
可產生出 128(主餐) * 95(點心) * 70(飲品) * 8(評價) = 共 6,809,600 種留言。
若主餐、點心、飲品出現不只一個,可產生的留言將會有更多種類,可讓我們的留言更有多樣性。
定義餐點品項(主餐、點心、飲品、評價) 程式碼片段
MainMeal_Fire = ["火烤牛肉堡","小華堡","華堡","辣味華堡","火烤雞腿堡"]
MainMeal_Fried = ["總匯辣腿堡","鱈魚堡","田園華鱈魚堡","小怪獸香豬脆雞","BK黃金詐雞"]
MainMeal_Cheese = ["重磅培根牛肉堡","重磅培根辣雞堡","安格斯牛堡","花生安格斯",\
"勁濃安格斯","犇牛堡","勁濃培根烤腿堡","鱈魚堡","田園華鱈魚堡"]
MainMeal_ALL_Description = ["份量十足","味道很棒","很滿足","很好吃","配料搭配剛好","用料新鮮"]
MainMeal_Fire_Description = ["肉汁很多","肉汁十足","口感獨特"]
MainMeal_Fried_Description = ["口感酥脆","酥脆可口"]
MainMeal_Cheese_Description = ["起司濃郁","起司香濃"]
Dessert_Fried = ["水牛城辣雞翅","水牛城辣味薯條","水牛城辣雞塊","BK黃金雞翅",\
"V型薯","洋蔥圈","勁濃起司薯","辣薯球","BK雞塊","薯條"]
Dessert_Ice = ["巧克力聖代","草莓聖代","濃縮咖啡聖代","冰淇淋"]
Dessert_ALL_Description = ["很美味","很好吃","物超所值"]
Dessert_Fried_Description = ["酥脆可口","口感酥脆","鹹香","味道很好"]
Dessert_Ice_Description = ["香甜可口","做的很用心","甜香四溢"]
Drink_Coffee = ["熱咖啡","卡布奇諾","拿鐵","冰拿鐵","美式研磨","冰美式研磨"]
Drink_Tea = ["熱紅茶","檸檬紅茶","無糖綠茶"]
Drink_Soda = ["激浪","百事","百事Light","七喜","華年達"]
Drink_Juice = ["柳橙汁"]
Drink_All_Description = ["很好喝","和餐點很搭"]
Drink_Tea_Description = ["茶味濃厚","很清爽"]
Drink_Coffee_Description = ["很有質感","口感平順","口感溫和","口感柔潤"]
Drink_Juice_Description = ["酸爽","充滿果粒"]
Drink_Soda_Description = ["氣泡充足","氣泡感十足"]
MainMeal_Comments_ALL =["用餐體驗良好","令人回味無窮"]
MainMeal_Comments_Here =["店員親切很用心服務","店員很細心待人親切","店員很有耐心","服務超讚的","客席區域很乾淨",]
呼叫組合 程式碼片段
半固定多選框
我們在 "隨機生成評價留言"時會從菜單中隨機挑選1~4樣主餐,我們可以按照當時的選擇來勾選表單,做出一份前後相符的問卷。
▼ 購買產品

代理IP與裝置變換
相同的IP位置或裝置重複填寫問卷會被系統排除,因此需要使用代理伺服器當作跳板
使問卷接受度提高。
更換IP: 代理IP
選單: 選單