1. 程式人生 > >python scrapy cookies 處理

python scrapy cookies 處理

  1 def start_requests(self):
  2 	cookies = 'anonymid=jcokuqwe................省略'
  3 	# 首先是對cookies進行分割以;為節點
  4 	ookies = {i.split("=")[0]:i.split("=")[1] for i in cookies.split(";")}
  5 	yield scrapy.Request(
  6 		self.start_urls[0],
  7 		callback=self.parse,
  8 		cookies=cookies
  9 	)
 10