Skip to content

Instantly share code, notes, and snippets.

@abidkhan484
Last active November 19, 2017 07:39
Show Gist options
  • Select an option

  • Save abidkhan484/f1ad296836de95a94b952c74e0e6fdf1 to your computer and use it in GitHub Desktop.

Select an option

Save abidkhan484/f1ad296836de95a94b952c74e0e6fdf1 to your computer and use it in GitHub Desktop.
import scrapy
class HackerrankSpider(scrapy.Spider):
name = 'hackerrank'
start_urls = ['http://www.hackerrank.com/login']
def parse(self, response):
form = {'login': 'myUserName', 'password': 'secret'}
# formxpath = "//input[@data-attr2='Login']"
return [scrapy.FormRequest.from_response(response,
formdata=form,
# formxpath=formxpath,
dont_click=True,
callback=self.after_login)]
def after_login(self, response):
if "authentication failed" in response.text:
self.logger.error("Login failed")
return
print('text of response after login request\n', response.text)
return [scrapy.http.Request('https://www.hackerrank.com/submissions/all',
callback=self.parse_test)]
# return [scrapy.http.Request('https://www.hackerrank.com/challenges/lonely-integer/submissions/code/58667241',
callback=self.parse_test)]
def parse_test(self, response):
print(response.text)
# print(response.selector.xpath('//a[@class="btn btn-inverse view-results backbone"]'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment