相同code現在無法使用:
import requests
cookies = {
"CLIENT%5FID": "20240508193926906%5F220%2E129%2E67%2E143",
"IS_TOUCH_DEVICE": "F",
"SCREEN_SIZE": "WIDTH=1920&HEIGHT=1080"
}
url = "https://goodinfo.tw/tw/StockDividendPolicyList.asp?MARKET_CAT=%E4%B8%8A%E5%B8%82&INDUSTRY_CAT=%E5%85%A8%E9%83%A8&YEAR=2024&INITIALIZED=T"
headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
'accept-encoding': 'gzip, deflate, br, zstd',
'accept-language': 'zh-TW,zh;q=0.5',
'cache-control': 'no-cache',
'pragma': 'no-cache',
'sec-ch-ua': '"Chromium";v="124", "Brave";v="124", "Not-A.Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'none',
'sec-fetch-user': '?1',
'sec-gpc': '1',
'upgrade-insecure-requests': '1',
"Referer": "https://www.google.com/"
}
session = requests.Session()
session.headers = headers
response = session.get(url,cookies=cookies)
content = response.content
decoded_string = content.decode('utf-8')
print(decoded_string)
測試正常