Python 2.7 Python Scrapy单击html按钮

Python 2.7 Python Scrapy单击html按钮,python-2.7,web-scraping,scrapy,Python 2.7,Web Scraping,Scrapy,我不熟悉scrapy,并将scrapy与Python2.7一起用于web自动化。我想在网站上点击一个html按钮,打开一个登录表单。我的问题是,我只想点击一个按钮,然后将控件转移到新页面。我读过所有类似的问题,但没有一个令人满意,因为它们都包含直接登录或使用selenium 下面是按钮的HTML代码,我想访问http://example.com/login其中有登录页面 <div class="pull-left"> <a href="http://example.co

我不熟悉scrapy,并将scrapy与Python2.7一起用于web自动化。我想在网站上点击一个html按钮,打开一个登录表单。我的问题是,我只想点击一个按钮,然后将控件转移到新页面。我读过所有类似的问题,但没有一个令人满意,因为它们都包含直接登录或使用selenium

下面是按钮的HTML代码,我想访问http://example.com/login其中有登录页面

<div class="pull-left">
    <a href="http://example.com/login" class="emplink">Employers</a>    

我是否需要在每次访问链接时使用“屈服”和回调到新功能,或者有其他方法可以做到这一点

您需要的是产生一个新的请求或更轻松地做出
响应。请按照以下步骤操作:


关于回调,它基本上取决于页面被解析的容易程度,例如,检查文档上的部分,您需要的是生成一个新的请求或更容易做出一个
响应

关于回调,它基本上取决于页面被解析的容易程度,例如,检查文档上的部分

import scrapy

class QuotesSpider(scrapy.Spider):
    name = 'pro'
    url =  "http://login-page.com/"


def start_requests(self):
    yield scrapy.Request(self.url, self.parse_login)


def parse_login(self, response):
    employers = response.css("div.pull-left a::attr(href)").extract_first()
    print employers
def parse_login(self, response):
    next_page = response.css("div.pull-left a::attr(href)").extract_first()
    if next_page is not None:
        yield response.follow(next_page, callback=self.next_page_parse)