python爬虫(五)多页码

来源:互联网 发布:分润系统源码 编辑:程序博客网 时间:2024/06/05 06:05
from bs4 import BeautifulSoupimport requestsimport timeurl = 'https://knewone.com/discover?page='def get_page(url,data=None):    wb_data = requests.get(url)    soup = BeautifulSoup(wb_data.text,'lxml')    imgs = soup.select('a.cover-inner > img')    titles = soup.select('section.content > h4 > a')    links = soup.select('section.content > h4 > a')    if data==None:            for img, title, link in zip(imgs, titles, links):                data = {            'img': img.get('src'),            'title': title.get('title'),            'link': link.get('href')        }                print(data)def get_more_pages(start,end):    for one in  range(start,end):        get_page(url+str(one))        time.sleep(2)get_more_pages(1,10)
0 0
原创粉丝点击