def start_requests(self):
if self.single_url:<EOL><INDENT>port = urlparse(self.single_url).port<EOL>if port:<EOL><INDENT>if port != self.port:<EOL><INDENT>self.port = port<EOL><DEDENT><DEDENT>else:<EOL><INDENT>yield scrapy.Request(<EOL>self.single_url,<EOL>callback=self.parse_item,<EOL>errback=self.handle_error<EOL>)<EOL>return<EOL><DEDENT><DEDENT>if self.login_email and self.login_password:<EOL><INDENT>login_url = (<EOL>URLObject("<STR_LIT>")<EOL>.with_hostname(self.domain)<EOL>.with_port(self.port)<EOL>.with_path(LOGIN_HTML_PATH)<EOL>)<EOL>yield scrapy.Request(<EOL>login_url,<EOL>callback=self.after_initial_csrf,<EOL>errback=self.handle_error<EOL>)<EOL><DEDENT>else:<EOL><INDENT>self.logger.info(<EOL>"<STR_LIT>"<EOL>)<EOL>auth_url = (<EOL>URLObject("<STR_LIT>")<EOL>.with_hostname(self.domain)<EOL>.with_port(self.port)<EOL>.with_path(AUTO_AUTH_PATH)<EOL>.set_query_params(<EOL>staff='<STR_LIT:true>',<EOL>course_id=self.course_key,<EOL>)<EOL>)<EOL>headers = {<EOL>b"<STR_LIT>": b"<STR_LIT:application/json>",<EOL>}<EOL>yield scrapy.Request(<EOL>auth_url,<EOL>headers=headers,<EOL>callback=self.after_auto_auth,<EOL>errback=self.handle_error<EOL>)<EOL><DEDENT>
Gets the spider started.
If both `self.login_email` and `self.login_password` are set,
this method generates a request to login with those credentials.
Otherwise, this method generates a request to go to the "auto auth"
page and get credentials from there. Either way, this method
doesn't actually generate requests from `self.start_urls` -- that is
handled by the `after_initial_login()` and `after_auto_auth()`
methods.