Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

302 Redirect after Login #15

Open
imukai opened this issue Feb 25, 2019 · 2 comments
Open

302 Redirect after Login #15

imukai opened this issue Feb 25, 2019 · 2 comments

Comments

@imukai
Copy link

imukai commented Feb 25, 2019

I can successfully populate and submit a login form with Scrapy. As can be common with logins the server sends back a 302 redirect to a main page that Scrapy sees as an error (a WebException).

I tried enabling .AllowAutoRedirect as well as AllowMetaRedirect on the ScrapingBrowser object with no change in behavior.

Please advise.

@imukai
Copy link
Author

imukai commented Feb 25, 2019

My current workaround is to trap for the exception and manually call the next page, but this seems less than ideal as relying on exceptions for normal flow is usually bad.

catch (AggregateException ex) {
    var inner = ex.InnerExceptions.First() as WebException;
    redoUrl = inner?.Response?.Headers["Location"];
    }

@dararish
Copy link
Contributor

@imukai as far as I can tell, HttpWebRequest throws an exception whenever a non-200 status code is returned. See #19 for a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants