我正在写一个程序在scrapy登录在scrape相同的数据从一个网站。它似乎是正确登录,据我所知,但当它登录它重定向到一个网页,我不希望它刮。我需要它去这个网页,https://www.starcitygames.com/myaccount/。如何让我的程序在登录后转到该页面
import scrapy
from ..items import NameItem
class LoginSpider(scrapy.Spider):
name = "LoginSpider"
start_urls = ["https://www.starcitygames.com/login"]
def parse(self, response):
return scrapy.FormRequest.from_response(
response,
formdata={'ex_usr_email': 'username', 'ex_usr_pass': 'password'},
callback=self.after_login
)
def after_login(self, response):
item = NameItem()
item["Name"] = response.css("div.column_data::text").get()
return item
您需要分为两个步骤:
相关问题 更多 >
编程相关推荐