我有一个起始网址,只想抓取一页,但是我想通过在start_url中输入1到50之间的一个随机数来随机选择该页面:
start_urls = ["http://www.modcloth.com/shop/bedding?sorting=loved&page=1"]
其中page =随机数
您可以使用标准random.randint
库功能。
from random import randint
start_urls = ["http://www.modcloth.com/shop/bedding?sorting=loved"
"&page={0}".format(randint(1,50))]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句