大家好,又上來打擾了,最近在爬蟲的時候遇到這個詞:
"宏碁電腦",發現爬下來時候會變成亂碼,
經爬文查詢後發現這樣的問題:
https://blog.hoamon.info/2008/05/python-big5.html
不過該解法似乎不能應用在python3.7
想問一下有沒有類似的情況該怎麼解@@?
補上網站:
https://tw.stock.yahoo.com/news/%E5%A4%96%E8%B3%87-%E8%B3%A3%E8%B6%85%E8%82%A1-%E5%AE%8F-%E7%A2%81-%E9%B4%BB-234706227.html
程式碼:
import requests
from bs4 import BeautifulSoup
url='https://tw.stock.yahoo.com/news/%E5%A4%96%E8%B3%87-%E8%B3%A3%E8%B6%85%E8%82%A1-%E5%AE%8F-%E7%A2%81-%E9%B4%BB-234706227.html'
req=requests.get(url)
bs=BeautifulSoup(req.text,'html.parser')
print(bs.find('h1').text)