我一直试图登录到一个网站与scrapy,但它不能正常工作
import scrapy
class BasicSpider(scrapy.Spider):
name = 'basic'
# allowed_domains = ['login']
start_urls = ['https://seller.digikala.com/account/login/?_back=https://seller.digikala.com/sellerinvoice/']
def parse(self, response):
# login = {}
return scrapy.FormRequest.from_response(
response,
formdata={'email': 'email', 'password': 'pass'},
callback=self.parse_item
)
def parse_item(self, response):
if response.body != None:
print(response.xpath("/html/body/div/aside[1]/div/header/a/img"))
1条答案
按热度按时间56lgkhnf1#
对于电子邮件和密码,你需要取
name
属性中的值。你可以用和我一样的方法检查登录是否成功,但是可能需要更改字符串。