Larisa-HSU / SCU_Python_Learning

homework1
0 stars 0 forks source link

爬蟲基礎學習 #40

Open Larisa-HSU opened 3 years ago

Larisa-HSU commented 3 years ago
import requests 
from bs4 import BeautifulSoup
choose=requests.get('https://www.ccclub.io/course/2021Spring')
ffile_ccClub = BeautifulSoup(choose.text,"html.parser")
ccClub=[]
tbody=ffile_ccClub.find("tbody")
trs=tbody.find_all("tr")
for tr in trs:
    tds=tr.find_all("td")
    date=tds[1].text##日期
    content=tds[2].text##上課內容
    ##if ""in content:
    if "announce" in content:
        ccClub.append(date)
print(ccClub)
Larisa-HSU commented 3 years ago
import requests 
from bs4 import BeautifulSoup 
choose=requests.get('https://www.ptt.cc/bbs/hotboards.html')##choose為自訂名稱
ffile_PPT = BeautifulSoup(choose.text,"html.parser")##ffile_PPT為自訂名稱
tbody=ffile_PPT.find("body")
div=tbody.find_all("div",{"class":"b-ent"})
for board in div:
    name=board.find("div",{"class":"board-name"}).text
    num=board.find("div",{"class":"board-nuser"}).text    
    if int(num)>=1000:
        print(name,num)