woaiyibao
woaiyibao
2019-04-12 11:22

爬虫如何用一个循环写出4个变量

  • python
  • mysql

https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?resource_id=28286&from_mid=1&&format=json&ie=utf-8&oe=utf-8&query=%E7%94%B5%E5%BD%B1&sort_key=16&sort_type=1&stat0=%E7%88%B1%E6%83%85&stat1=%E5%A4%A7%E9%99%86&stat2=2017&stat3=&pn=0

这里面 stat0 stat1 stat2 都固定有9种左右
pn是以8的倍数递增

urlbase = "https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?resource_id=28286&from_mid=1&&format=json&ie=utf-8&oe=utf-8&query=%E7%94%B5%E5%BD%B1&sort_key=16&sort_type=1&stat0=&stat1=&stat2=&stat3=&pn="
urllist =[]
for i in range(1,124):
        url = urlbase+str(8*i)
        urllist.append(url)

现在想写一个循环能够把所有种类都放入一个list 不知道怎么办了= =

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答