2
我有一個起始網址,只需要爬一個頁面,但我想通過在START_URL輸入1和50之間的隨機數隨機選擇一個頁面:Scrapy單START_URL隨機數
start_urls = ["http://www.modcloth.com/shop/bedding?sorting=loved&page=1"]
where page =隨機數
我有一個起始網址,只需要爬一個頁面,但我想通過在START_URL輸入1和50之間的隨機數隨機選擇一個頁面:Scrapy單START_URL隨機數
start_urls = ["http://www.modcloth.com/shop/bedding?sorting=loved&page=1"]
where page =隨機數
您可以使用標準的random.randint
庫函數。
from random import randint
start_urls = ["http://www.modcloth.com/shop/bedding?sorting=loved"
"&page={0}".format(randint(1,50))]