三、爬動態數據
阿新 • • 發佈:2017-10-28
logs port ima art -i mage log 自動加載 images
from bs4 import BeautifulSoup import requests import time url=‘https://knewone.com/?page=5‘ def get_page(url,data=None): wb_data = requests.get(url) soup = BeautifulSoup(wb_data.text,‘lxml‘) # print(soup) imgs = soup.select(‘a.cover-inner > img‘) titles = soup.select(‘section.content > h4 > a‘) links = soup.select(‘section.content > h4 > a‘) 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)
該網站動態表現在不知道頁碼有多少個,頁面往下翻,頁面就會自動加載上來
三、爬動態數據