I am gonna to scrape https://movie.douban.com/subject/1292052/ this page
but the url redirect to http://m.douban.com/movie/subject/1292052 how did I back to the first page and use the first page's parse way(xpath) to go on? thanks!
I am gonna to scrape https://movie.douban.com/subject/1292052/ this page
but the url redirect to http://m.douban.com/movie/subject/1292052 how did I back to the first page and use the first page's parse way(xpath) to go on? thanks!
The reason you are being redirected to the mobile site is because your user agent is not a known desktop browser.
You can modify USER_AGENT
variable in settings.py
to something like USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
If you insist on not getting redirected, you can add meta
variable in your request with {'dont_redirect': True, 'handle_httpstatus_list': [302]}
. This way, you won't get redirected.