[問題] 新手爬蟲請益
板上的各位大大們好,最近剛開始自學爬蟲,知道可以用find_all去抓所有同標籤和屬性
下的網頁文字內容,但想請問如果我想抓html裡面的特定內容,沒有顯示在網頁的那種,
如下圖的黃色miaowu2020的部分該如何下手呢?謝謝!
https://i.imgur.com/NhgYWme.jpg

附上我抓其他網頁內容的程式
https://i.imgur.com/uuSK3Io.jpg

--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.82.62.74 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1662051879.A.BCC.html
→
09/02 03:14,
2年前
, 1F
09/02 03:14, 1F
剛試過好像不是,因為我是想找所以data-item-id後面的名字QQ
推
09/02 03:50,
2年前
, 2F
09/02 03:50, 2F
謝謝J大,剛剛研究一下用get好像可以抓出來了,但多了很多顯示為none 的值就是...
https://i.imgur.com/POoLHJe.jpg


※ 編輯: etudiant (111.82.62.74 臺灣), 09/02/2022 13:24:58
推
09/02 14:37,
2年前
, 3F
09/02 14:37, 3F
→
09/02 14:55,
2年前
, 4F
09/02 14:55, 4F
※ 編輯: etudiant (111.82.62.74 臺灣), 09/02/2022 15:45:44
→
09/02 16:16,
2年前
, 5F
09/02 16:16, 5F
→
09/02 16:28,
2年前
, 6F
09/02 16:28, 6F
import requests
import bs4
import time
import random
URL="https://www.zeczec.com/categories?category=16&page=1&type=crowdfunding"
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKi
t/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'}
response = requests.get(URL,headers=headers)
soup = bs4.BeautifulSoup(response.text,"html.parser")
cash = soup.find_all('div','font-bold leading-8')
for c in cash:
print(c.text.strip())
for name in soup.find_all('a'):
print(name.get('data-item-id'))
delay_choices = [8, 5, 10, 6, 20, 11]
delay = random.choice(delay_choices)
time.sleep(delay)
※ 編輯: etudiant (111.82.62.74 臺灣), 09/02/2022 16:29:08
→
09/02 16:32,
2年前
, 7F
09/02 16:32, 7F
→
09/02 16:32,
2年前
, 8F
09/02 16:32, 8F
→
09/02 16:32,
2年前
, 9F
09/02 16:32, 9F
→
09/02 16:32,
2年前
, 10F
09/02 16:32, 10F
推
09/02 16:47,
2年前
, 11F
09/02 16:47, 11F
→
09/02 19:26,
2年前
, 12F
09/02 19:26, 12F
→
09/02 19:31,
2年前
, 13F
09/02 19:31, 13F
→
09/02 20:04,
2年前
, 14F
09/02 20:04, 14F
→
09/02 20:20,
2年前
, 15F
09/02 20:20, 15F
→
09/02 21:18,
2年前
, 16F
09/02 21:18, 16F
→
09/02 21:18,
2年前
, 17F
09/02 21:18, 17F
Python 近期熱門文章
PTT數位生活區 即時熱門文章