python实战第一周大作业:爬取一页商品数据。
直接上运行结果如图:
代码如下:
from bs4 import BeautifulSoup
import requests
import time
url = 'http://bj.58.com/pbdn/0/'
#入口函数
def get_url(url):
web_data = requests.get(url)
soup = BeautifulSoup(web_data.text,'lxml')
links = get_links(soup.select('td.t > a'))