The Seven Year Itch.

MENU

我的第一个爬虫

January 23, 2017 • Read: 262 • Python

我就先不做任何的解释了。。。。新手。。

#coding-utf8

from bs4 import BeautifulSoup

import requests

res = requests.get('http://tangsanshui.com')

soup = BeautifulSoup(res.text,'lxml')

for news in soup.select('.article_exp'):
    href =  news.a['href']

    time = news.select('.article_exp_time')[0].text

    title  =  news.select('h2')[0].text

    print title+href+'\n'+time

请输入图片描述

Tags: None
Archives QR Code
QR Code for this page
Tipping QR Code