【发布时间】:2013-12-20 13:09:20
【问题描述】:
我正在通过 Scrapy 抓取一些页面(在同一域下)。
有一些特殊的页面是由JS生成的,所以我使用ScrapyJS并将页面加载到webview中,这样JS就可以执行了。但是 webview 中加载的网页是对网站的新请求。 webview 中的响应会将页面重定向到站点登录页面,这不是我想要的。
在我看来,我已经在 MyTestSpider 中登录了该站点。如果 webview 的请求可以持有/共享/读取来自 MyTestSpider 的 cookie,它将使 JS 生成的页面表现良好,就像通过正确的用户登录一样,而不是重定向到站点登录页面。
我所拥有的: 类 MyTestSpider(CrawlSpider):
def start_requests(self):
self.prelogin()
def prelogin(self):
//login prepares
def login(self):
//login the website and hold the cookie
def parse_item(self, response):
//parse the items
有没有人对此问题有更好的解决方案? 任何帮助都会得到帮助......:p
【问题讨论】:
标签: javascript python cookies scrapy