Passed
Pull Request — master (#8)
by Aurélien
01:03
created

AmazonChecker.spiders.AmazonChecker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A AmazonChecker.parse() 0 8 3
A AmazonChecker.after_login() 0 2 1
1
# -*- coding: utf-8 -*-
2
import scrapy
3
4
5
class AmazonChecker(scrapy.Spider):
6
    name = 'AmazonChecker'
7
    allowed_domains = ['amazon.fr']
8
    start_urls = ['https://www.amazon.fr/ap/signin?_encoding=UTF8&ignoreAuthState=1&openid.assoc_handle=frflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.fr%2F%3Fref_%3Dnav_custrec_signin&switch_account=']
9
10
    def parse(self, response):
11
        if not self.username or not self.password:
12
            print ('pas bon')
13
        else:
14
            return scrapy.FormRequest.from_response(
15
                    response,
16
                    formdata={'username': self.username, 'password': self.password},
17
                    callback=self.after_login
18
                    )
19
20
    def after_login(self, response):
21
        print (response.body)
22