PTT 股版爬蟲(Python)

import requests
from bs4 import BeautifulSoup


res = requests.get('https://www.ptt.cc/bbs/Stock/index.html')
soup = BeautifulSoup(res.text, 'html.parser')

for article in soup.select('.r-ent a'):
    url = 'https://www.ptt.cc' + article['href']
    res = requests.get(url)
    #soup = BeautifulSoup(res.text, 'html.parser')
    print (url,article.text)
   
    res = requests.get(url)
    soup = BeautifulSoup(res.text, 'html.parser')

留言

這個網誌中的熱門文章

教你如何看原始碼(以下載伊莉影片區的影片為例) (107/5/22更新)