爬取knewone上的信息

爬取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>

    原文作者:宁静消失何如
    原文地址: https://www.jianshu.com/p/bee9202939f1
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞