MySpider试图描述加载更多操作点击,导致网页上的更多项加载更新。这一直持续到没有更多需要加载。Scrapy:POST请求返回JSON响应(200 OK),但数据不完整
yield FormRequest(url,headers=header,formdata={'entity_id': '70431','profile_action': 'review-top','page':str(p), 'limit': '5'},callback=self.parse_review)
header = {#'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0',
'X-Requested-With': 'XMLHttpRequest',
'Host': 'www.zomato.com',
'Accept': '*/*',
'Referer': 'https://www.zomato.com',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'dont_filter':'True' }
url = 'https://www.zomato.com/php/social_load_more.php'
收到的响应是json响应。
jsonresponse = json.load(response)
,我也看到 -
('data==', {u'status': u'success', u'left_count': 0, u'html': u"<script type='text/javascript'>if (typeof initiateLaziness == 'function') initiateLaziness() </script>", u'page': u'1', u'more': 0})
你看到我得到的地位,left_count,页面,更多的回应。 但是我对'html'感兴趣。不幸的是,它的在纠正值这点我接受,如果通过浏览器完成的(检查网络通话和验证)
预计“HTML”是----
<div><a> very long html stuff...............................................<div><script type='text/javascript'>if (typeof initiateLaziness == 'function') initiateLaziness() </script>
我只接收稍后部分
<script>...................................</script>.
真正的html东西丢失。
需要注意的是,我确实收到了回复,但只有'html'不完整。所有好的休息。我相信这可能与动态生成的html有关。但我对此有任何线索。
scrapy中间件没有添加内容长度。也不允许我添加一个。将它添加到标题时,响应失败400。
请求头被实际发送到服务器:
{'Accept-Language': ['en'], 'Accept-Encoding': ['gzip, deflate,br'], 'Dont_Filter': ['True'], 'Connection': ['keep-alive'], 'Accept': ['*/*'], 'User-Agent': ['Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0'], 'Host': ['www.zomato.com'], 'X-Requested-With': ['XMLHttpRequest'], 'Cookie': ['zl=en; fbtrack=9be27330646d24088c56c2531ea2fbf5; fbcity=7; PHPSESSID=2338004ce3fd540477242c3eaee685168163bd05'], 'Referer': ['https://www.zomato.com'], 'Content-Type': ['application/x-www-form-urlencoded; charset=UTF-8']})
任何一个可以请帮我,如果我在这里缺少什么? 或者我可以发送发送内容长度/或让中间件发送给我? 非常感谢。
我注意到的一件事是,将“Content-Length:50”添加到标题后,响应失败。而且,中间件不会自动将其添加到请求的标题中。 –