循环搜索结果页面并解析数据

时间:2017-05-26 10:17:59

标签: python beautifulsoup

我只是想让Python查看网站搜索结果的所有网页:

remainder = "latter_part_of_url"

page = '?s=0'

urlstring = 'https://domain/search/' + str(page) + str(remainder)

pagenumber = str(page)+120

for i in range(120, 100000, 120):
    # I am trying to increment by 120, how do I do that?

print(urlstring)

1 个答案:

答案 0 :(得分:0)

这不是一件简单的事情:

    for new_page_num in range(int(page)+120, 100000, 120):
        urlstring = 'https://domain/search/' + str(new_page_num) + str(remainder)

我会使用一些字符串格式而不是+。