各位大大,您好,
我有試過 selenium 或者有用 requests
selenium 會遇到要點選連結,發簡訊的問題
requests 我用 cookies 的方式
好像是不正確的,因為跑很久才會出來不正確的
回傳的信息: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
請問是否不能透過 cookies 登入的方式?
還請各位大大是否可以告知,謝謝!
import requests
import re
import pandas as pd
import http.cookiejar
from bs4 import BeautifulSoup
from fake_useragent import UserAgent
from lxml import etree, html
import json
url = 'https://seller.shopee.tw/portal/product/list/all'
headers = requests.utils.default_headers()
headers.update({
'Host': 'seller.shopee.tw',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Language': 'zh-TW,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Accept-Encoding': 'gzip, deflate, br',
'Referer': 'https://seller.shopee.tw/account/signin?next=index.index¶ms=%5B%5D',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Content-Length': '175',
'Connection': 'keep-alive',
'cache-control': 'max-age=0',
'Cookie':'SPC_CDS=c6d83195-36d0-44d0-8cf3-28048ab0a801; SPC_SC_SA_TK=; SPC_SC_SA_UD=; SC_DFP=8fIlJwr9WELra90iOnVKcX5q50C77BVq; SPC_F=WUoPxOooqqf7bZ4zi9YbiC51pOD8kAF4; _gcl_au=1.1.554183486.1650289319; SPC_SI=mall.yG6gp8FzRwFbCWAUMpO672W58fJwTtun; _gid=GA1.2.430041453.1650289320; SC_SSO=-; SC_SSO_U=-; _QPWSDCXHZQA=de866c47-e411-4af3-e561-2c59a7c453ec; UYOMAPJWEMDGJ=; _ga_RPSBE3TQZZ=GS1.1.1650334609.103.0.1650334609.60; _ga=GA1.1.11249714.1650289320; G_ENABLED_IDPS=google; shopee_webUnique_ccd=f70yT08jegushoSqNREyFg%3D%3D%7CFriBOLTO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OV+F4PbFs0tfIRj0CSaS4lyOa1kTuGRy3rUsLHeC1VdNEk3CmHjmIwRk2NYLcdttubYa8kZu0ygQao9WHKC5wmwJrUhyfprOL25imvks2kiuNCeQi0lP/NCGFzQ="'
})
r = requests.get(url, headers=headers)
print(r.status_code)
print(r.history)
print(r.url)