Skip to content

Commit

Permalink
cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
yqh231 committed Jan 29, 2017
1 parent 026a12d commit 6f87c1e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions myScrapy/src/MyScrapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
class test(object):
def start_request(self):
for i in xrange(1, 5):
yield Request(url = 'http://www.baidu.com/', method = 'GET', callback = self.deal_response)
yield Request(url = 'http://www.baidu.com/', method = 'GET', callback = self.deal_response, meta = {'cookieJar':1})

def deal_response(self, response):
for i in xrange(1, 5):
yield Request(url = 'http://www.baidu.com/', method = 'GET', callback = self.deal_response1)
print response._cookie

def deal_response1(self, response):
print response.xpath("//head/title")[0].text
print response._response_string.xpath("//head/title")[0].text


app.run(execute_app = test())

0 comments on commit 6f87c1e

Please sign in to comment.