import requests from bs4 import BeautifulSoup .get("https://www.ptt.cc/bbs/MobileComm") soup = BeautifulSoup(r.text, "html.parser") sel = soup.select("div.title a") for s in sel: print(s["href"],s.text) r = requests
目前分類:Python (2)
- Oct 01 Thu 2020 14:40
Python_爬蟲
- Sep 28 Mon 2020 10:12
0928_Python_練習
def data_item(check_code): if(check_code == 'A'): return "滷肉飯" elif(check_code == 'B'): return "火鍋" elif(check_code == 'C'): return "薯條" input_value = input("請選擇套餐(A,B,C):") print("今天我想來點>>>%s" %(data_item(input_value))) print("隨便來點答案吧") print(data_item('A'))
前面def 定義data_item裡面的程式
後面縮排 代表執行主程式