我想对网页中向下滚动产生的内容进行反向工程。问题出在url https://www.crowdfunder.com/user/following_page/80159?user_id=80159&limit=0&per_page=20&screwrand=933
上。screwrand
似乎不遵循任何模式,所以反向url不起作用。我正在考虑使用Splash进行自动渲染。如何使用Splash像浏览器一样滚动?非常感谢!以下是两个请求的代码:
request1 = scrapy_splash.SplashRequest(
'https://www.crowdfunder.com/user/following/{}'.format(user_id),
self.parse_follow_relationship,
args={'wait':2},
meta={'user_id':user_id, 'action':'following'},
endpoint='http://192.168.99.100:8050/render.html')
yield request1
request2 = scrapy_splash.SplashRequest(
'https://www.crowdfunder.com/user/following_user/80159?user_id=80159&limit=0&per_page=20&screwrand=76',
self.parse_tmp,
meta={'user_id':user_id, 'action':'following'},
endpoint='http://192.168.99.100:8050/render.html')
yield request2
3条答案
按热度按时间gg58donl1#
要滚动页面,您可以编写一个自定义呈现脚本(请参阅http://splash.readthedocs.io/en/stable/scripting-tutorial.html),如下所示:
若要呈现此脚本,请使用“execute”终结点而不是render.html终结点:
c8ib6hqw2#
感谢Mikhail,我尝试了你的滚动脚本,它的工作,但我也注意到,你的脚本滚动太多的一次,一些js没有时间太渲染和跳过,所以我做了一些小的变化如下:
woobm2wo3#
我不认为设置硬编码的滚动数量对于无限滚动页面是一个好主意,所以我修改了上面提到的代码如下: