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')
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')
留言
張貼留言