楼主:
shot0512 (诚实豆沙包)
2020-07-23 17:45:44小弟是爬虫菜鸟新手
最近在学习如何爬虫
从最基本的静态网页开始爬起
以下是我的CODE
import requests
from bs4 import BeautifulSoup
import time
url = "http://www.eslite.com/Search_BW.aspx?query=python&searchType=&page=1"
html = requests.get(url).text
soup = BeautifulSoup(html, 'html.parser') #先输入的是要解析的文件名称 后面是
parser
page = 1
all_titles=[]
def parse(html, page):
print(page)
all_td_tags = soup.find_all('td', class_="name")
for item in all_td_tags:
title=item.a.span.text.strip()
all_titles.append(title)
next_page_node = soup.find('a',
id="ctl00_ContentPlaceHolder1_pager1_next") #下一页的node
print (next_page_node.get('href'))
print("