def start_requests(self): print('start_requests: ') return [ quixote.Request('http://' + self.host + ':8000/login', headers=self.header, callback=self.do_login) ]
def start_requests(self): print('start_requests: ') while True: self.i += 1 url = 'http://' + self.host + ':8000/test_cookies/test_cookies_' + str( self.i) # yield quixote.Request(url, dont_filter=True, headers=self.header, callback=self.parse) yield quixote.Request(url, dont_filter=True, headers=self.header) if self.i > 5000: break
def before_start_requests(self): print('before_start_requests 4: ') yield quixote.Request('http://' + self.host + ':8000/login', headers=self.header, callback=self.do_login) login_url = 'http://' + self.host + ':8000/login' login_data = { "username": "******", "password": "******", '_xsrf': self._xsrf } yield quixote.FormRequest(url=login_url, method='POST', formdata=login_data, headers=self.header, callback=self.is_login)
def is_login(self, response): print(response) if "welcome" in response.url: print("登录成功") # for i in range(100): i = 0 while True: i += 1 if i > 100000: break url = 'http://' + self.host + ':8000/test_cookies/test_cookies_' + str( i) yield quixote.Request(url, dont_filter=True, headers=self.header, callback=self.parse) else: print("登录失败")
def parse(self, response): # with open(self.logs_path+'html01/mm.html', 'a') as f: # f.write(response.text) self.j += 1 if self.j in [100, 1500, 20000, 25000]: url = 'http://' + self.host + ':8000/test_cookies/PARSE_RECORD_%s' + 'W' * 3000 yield quixote.Request(url % self.j, dont_filter=True, headers=self.header) yield quixote.Request(url % (self.j + 1), dont_filter=True, headers=self.header) yield quixote.Request(url % (self.j + 2), dont_filter=True, headers=self.header) yield quixote.Request( 'http://' + self.host + ':8000/test_cookies/OOOOOOOOOOO_PARSE_RECORD_%s' % (self.j + 3), dont_filter=True, headers=self.header) yield quixote.Request(url % (self.j + 4), dont_filter=True, headers=self.header) yield quixote.Request('http://' + self.host + ':8000/aaa/HttpErrorMiddleware_%s' % (self.j + 8), dont_filter=True, headers=self.header) yield quixote.Request('http://' + self.host + ':8000/bbb/HttpErrorMiddleware%s' % (self.j + 9), dont_filter=True, headers=self.header) time.sleep(0.05) item = TestItem() item['status'] = response.status item['url'] = response.url item['pipeline'] = list() item['q'] = '' yield item