how to get the item in the link address

way 1:

url = ['www.baibai.cn/page/1/','www.baibai.cn/page/2/]

#get item from www.baibai.cn/page/1/,the result is 1
page = response.url.split("/")[-2]
#make the filename,if page in 1,the filename is result-1.html
filename = 'result-%s.html' % page

way 2:

        links = ['/bw/toubu', '/bw/toubu/yanke','/bw/toubu/yarrke']
        links_size = [0]
        start_urls = []
        for link in links:
        conditions = link.replace('/bw/', '').split('/')
        cc = 1
        for c in conditions:
            print('condition'+str(cc)+':'+c + ' ')
            cc=cc+1

猜你喜欢

转载自blog.csdn.net/u014229742/article/details/81938588