爬取knewone上的信息-- coding: utf-8 -

爬取knewone上的信息 <pre> author = 'LEE'

-- coding: utf-8 -

from bs4 import BeautifulSoup import time import requests import time import io import sys import urllib.request sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')

url = 'https://knewone.com/things/?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') #print(soup) 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_page(start,end): for one in range(start,end): get_page(url+str(one)) time.sleep(1)

get_more_page(1,10)

</pre>

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券