我正在尝试从博客的每个页面获取所有博客标题,但到目前为止我只能从该博客的最后一页生成输出
RUN glide install
RUN go install
WORKDIR "../bin"
RUN myapp
答案 0 :(得分:0)
试试这个。它将为您提供不同页面的所有标题:
import requests
from bs4 import BeautifulSoup
base_url = 'http://www.madame-love.com/page/{}/'
for link in [base_url.format(page) for page in range(1,5)]: #just input the highest page number in place of 5
res = requests.get(link)
soup = BeautifulSoup(res.text, 'lxml')
for titles in soup.select('h2.entry-title a'):
print(titles.text)